You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I provide an example string on a List/array object which is a JSON representation of a list, then the output of that in the Yaml OpenAPI spec should be a list. Very similar logic to the special logic of an example which is a JSON map.
Actual Behaviour
The JSON array string is simply output into the yaml file as a string.
Steps To Reproduce
Create a Java class with this type of structure:
@Schema(description = "Street lines of the address", example = "[\"123 Main St\", \"Suite 517\"])
List<String> lines;
the Yaml output will look like this:
properties:
lines:
type: arraydescription: Street lines of the addressexample: "[\"123 Main St\", \"Suite 517\"]"items:
type: string
When ideally it would be this:
properties:
lines:
type: arraydescription: Street lines of the addressexample:
- 123 Main St
- Suite 517items:
type: string
I think another special case within this code could solve the issue:
StringschemaExample = (String) annValues.get("example");
if (StringUtils.isNotEmpty(schemaExample)) {
try {
schemaToBind.setExample(OpenApiUtils.getConvertJsonMapper().readValue(schemaExample, Map.class));
// NEW CODE HERE: Try to read the value as a list and set the example accordingly
} catch (JsonProcessingExceptione) {
schemaToBind.setExample(schemaExample);
}
}
What makes this difficult is Swagger seems to handle it just fine without this change, however not all tools are as forgiving.
Environment Information
Micronaut OpenApi version 6.5.1
Example Application
No response
Version
4.3.8
The text was updated successfully, but these errors were encountered:
Expected Behavior
If I provide an example string on a List/array object which is a JSON representation of a list, then the output of that in the Yaml OpenAPI spec should be a list. Very similar logic to the special logic of an example which is a JSON map.
Actual Behaviour
The JSON array string is simply output into the yaml file as a string.
Steps To Reproduce
Create a Java class with this type of structure:
the Yaml output will look like this:
When ideally it would be this:
I think another special case within this code could solve the issue:
What makes this difficult is Swagger seems to handle it just fine without this change, however not all tools are as forgiving.
Environment Information
Micronaut OpenApi version 6.5.1
Example Application
No response
Version
4.3.8
The text was updated successfully, but these errors were encountered: