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
I am encountering an issue when trying to parse OpenAPI JSON 3.1.0 examples of the Petstore. It seems that the ExampleBuilder class from io.swagger.oas.inflector.examples.ExampleBuilder does not support parsing JSON Schema, which is generated by the Swagger parser for 3.1.0 OpenAPI specs.
Observation
Upon reviewing the code of the ExampleBuilder class, it appears that there is no support for parsing JSON Schema.
Steps to Reproduce
Obtain the Petstore OpenAPI JSON 3.1.0 example.
Attempt to parse it using the Swagger parser and utilize the ExampleBuilder class to generate a JSON Example from the schema object.
Expected Behavior
The ExampleBuilder class should be able to parse the JSON Schema generated by the Swagger parser for 3.1.0 OpenAPI specs.
Actual Behavior
The ExampleBuilder class fails to parse the JSON Schema, resulting in a blank JSON example without keys and values.
Code Snippet.
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true);
parseOptions.setResolveFully(true);
SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation(specUrl, null, parseOptions);
if (parseResult.getMessages() != null && !parseResult.getMessages().isEmpty()) {
for (String message : parseResult.getMessages()) {
System.out.println("Parsing message: " + message);
}
}
OpenAPI openAPI = parseResult.getOpenAPI();
Map<String, Schema> definitions = openAPI.getComponents().getSchemas();
Schema model = definitions.get("Pet");
Example example = ExampleBuilder.fromSchema(model, model.getProperties());
SimpleModule simpleModule = new SimpleModule().addSerializer(new JsonNodeExampleSerializer());
Json.mapper().registerModule(simpleModule);
String jsonExample = Json.pretty(example);
System.out.println(jsonExample);
Problem
Observation
Steps to Reproduce
Expected Behavior
Actual Behavior
Code Snippet.
Dependencies (from pom.xml)
@fehguy and @gracekarina I have taken latest swagger-inflector version. If anyone knows any solution then please let me know.
The text was updated successfully, but these errors were encountered: