Various improvements to schema binding#745
Various improvements to schema binding#745graemerocher merged 6 commits intomicronaut-projects:masterfrom altro3:fix_lost_example
Conversation
altro3
commented
Jun 12, 2022
- kotlin 1.7.0
- Improved test for complex OpenAPIDefinition
- Fixed lost default value in schema (on class level)
- Fixed lost default, example, deprecated, accessMode properties, when use Schema on property level
- Fixed rename property when use Schema on property level
| Optional<io.swagger.v3.oas.annotations.media.Schema.AccessMode> schemaAccessMode = schemaAnn.get("accessMode", io.swagger.v3.oas.annotations.media.Schema.AccessMode.class); | ||
| if (schemaAccessMode.isPresent()) { | ||
| if (schemaAccessMode.get() == io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY) { | ||
| schemaToBind.setReadOnly(true); | ||
| schemaToBind.setWriteOnly(null); | ||
| } else if (schemaAccessMode.get() == io.swagger.v3.oas.annotations.media.Schema.AccessMode.WRITE_ONLY) { | ||
| schemaToBind.setReadOnly(false); | ||
| schemaToBind.setWriteOnly(null); | ||
| } else if (schemaAccessMode.get() == io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_WRITE) { | ||
| schemaToBind.setReadOnly(null); | ||
| schemaToBind.setWriteOnly(null); | ||
| } | ||
| } |
There was a problem hiding this comment.
Not critical but this code can be written more cleanly with something like:
schemaAnn.enumValue("accessMode", io.swagger.v3.oas.annotations.media.Schema.AccessMode.class)
.ifPresent(accessMode -> {
switch(accessMode) {
case READ_ONLY:
schemaToBind.setReadOnly(true);
schemaToBind.setWriteOnly(null);
break;
case WRITE_ONLY:
schemaToBind.setReadOnly(false);
schemaToBind.setWriteOnly(null);
break;
}
});Apart from that is setting write only to null correct?
There was a problem hiding this comment.
@graemerocher I don't now, sorry. This block copypasted from swagger lib
There was a problem hiding this comment.
@graemerocher Your proposal is not so simple, because would require making the schemaToBind variable finalized. In this case, I think that this block is better left as is.
…efault value ehn schema used on class level. Add rename property feature by schema name
|
@graemerocher Hi! Could anyone review my pull requests? Because I want to continue improve this module and now it's already 6 PR open from me and need to merge them so that there are fewer problems with conflicts |
|
@altro3 was away last week, apologies for the delay |
