micronaut-openapi
micronaut-openapi copied to clipboard
Bug fixes. Add support enum annotations
- Added support for enum values with JsonProperty annotation (fix #471).
- Added support JsonAnySetter annotation (fix #138)
- Fix wrong logic for property name when used Schema and JsonProperty annotations (fix #787)
- Fixed #134
- Fix incorrect schema when set type for property level annotation (fixed #792)
- Fix field javadoc properties parsing.
- Fix invalid defaultValue and allowValues types (have always been String)
- Fix
example
field with null value (always addedexample: null
to yaml file) - Removed unnecessary
required: false
field in final yaml file - Upgrade libs:
Micronaut 3.6.1 Gradle 7.5.1 Groovy 3.0.12
Could you bump the minor snapshot version? Upgrading to new minors requires a minor version bump
@graemerocher Sure. Done
@graemerocher Could you merge these changes and relese them? Want to use javadoc parser on field level, but withut these changes it doesnt wotk :-(
@altro3 Not sure if this is related, however I upgrade from Micronaut 3.4.1 -> 3.6.1 just now and in 3.4.1 the Swagger generated the .yml properly with Enum examples using the @Shchema annotation.
In 3.4.1 I had the following
@Schema(implementation = CloudProvider.class,
defaultValue = "AWS",
example = "AWS",
description = "" +
"Cloud Provider." +
"\n- AWS" +
"<br />Amazon Web Services. " +
"\n- AZURE" +
"<br />Microsoft Azure cloud." +
"\n- GCP" +
"<br />Google Cloud Platform." +
"\n- NA" +
"<br />Not applicable (Self hosting site)."
)
@Validated
@Introspected
//@Serdeable
public enum CloudProvider implements Serializable {
AWS("Amazon Web Services"),
AZURE("Microsoft Azure"),
GCP("Google Cloud Platform"),
NA("Not applicable");
private String cloudProvider;
CloudProvider(String cloudProvider) {
this.cloudProvider = cloudProvider;
}
public String getCloudProvider() {
return cloudProvider;
}
}
However, after upgrading to Micronaut 3.6.1 I started to see this
Error converting [{"description":"Cloud Provider.\n- AWS<br />Amazon Web Services. \n- AZURE<br />Microsoft Azure cloud.\n- GCP<br />Google Cloud Platform.\n- NA<br />Not applicable (Self hosting site).","defaultValue":"AWS","example":"AWS"}]: to class io.swagger.v3.oas.models.media.Schema: Cannot construct instance of `java.util.LinkedHashMap` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('AWS')
And after some testing I had to remove all defaultValue I had defined in my @Schema for ENUMs to fix above issue.
In the PR above you mention
Fix invalid defaultValue and allowValues types (have always been String)
Fix example field with null value (always added example: null to yaml file)
Why is it always added as null to the yaml file? I believe default values was working properly as strings previously?
@JouperCoding Hi! Ok, got it. I'll check it on the weekend
@JouperCoding fixed it in this PR
Sorry for the delay, was on vacation
@graemerocher No problem. I realized that you have a vacation according to the statistics of your activity in github ;-)