-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Translating a version 2 specification using Responses with Inline Schema and additionalPropeties: false fails to capture details of response #1552
Comments
I just ran into this except that it doesn't seem to have anything to do with "additionalProperties". Example: import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.core.models.ParseOptions;
import io.swagger.v3.parser.core.models.SwaggerParseResult;
public class FooTest {
public static void main(String[] args) {
ParseOptions options = new ParseOptions();
options.setResolve(true);
OpenAPIParser parser = new OpenAPIParser();
SwaggerParseResult result = parser.readContents(
"swagger: \"2.0\"\n"
+ "info:\n"
+ " version: \"1.0\"\n"
+ " title: \"test\"\n"
+ "host: \"foo\"\n"
+ "paths:\n"
+ " /example:\n"
+ " get:\n"
+ " consumes:\n"
+ " - \"application/json\"\n"
+ " produces:\n"
+ " - \"application/json\"\n"
+ " responses:\n"
+ " 200:\n"
+ " $ref: \"#/responses/something\"\n"
+ "responses:\n"
+ " something:\n"
+ " description: \"my response\"\n"
+ " schema:\n"
+ " title: \"my schema\"\n"
+ " properties:\n"
+ " foo:\n"
+ " type: string\n"
+ "", null, options);
System.out.println("errors: " + result.getMessages()); // no errors
Schema<?> schema = result.getOpenAPI().getPaths()
.get("/example").getGet()
.getResponses().get("200").getContent()
.get("application/json").getSchema();
System.out.println("title: " + schema.getTitle()); // found title
System.out.println("properties: " + schema.getProperties()); // null properties
}
} |
Thanks for reporting this. It has been fixed in #1849 (available in latest Please check v1 branch if your intention is instead to parse/validate/resolve a Swagger / OpenAPI 2.0 spec. Closing ticket, please reopen if you're still experiencing issues |
In the Java version of the parser you have the following specification:
Using
OpenAPI api = new OpenAPIParser().readContents(yml, null, new ParseOptions()).getOpenAPI();
results in the response
Response
having a schema object with no properties. As the properties are ignored as the parser believes there ire additionalProperties when in fact there are noneThis can be tracked to a possible issue with
io.swagger.models.utils.PropertyModelConverter#modelToProperty
lines 25-47. With additionalProperties being false lines 25-47 should not be executed howevere the valueadditionalProperties: false
is instead being translated into an actualio.swagger.models.properties.Property
instead of it generating a null object.The text was updated successfully, but these errors were encountered: