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
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true);
parseOptions.setResolveRequestBody(true);
parseOptions.setResolveFully(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("src/main/resources/openapi-properties-additionalProperties.json", null,
parseOptions);
It works perfect without any issues. swagger-parser can parse both properties and additionalProperties. However, when I change the requestBody structure from
"requestBody": {
"description": "Update an existent pet in the store",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
to
"requestBody": {
"description": "Update an existent pet in the store",
"content": {
"application/json": {
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/Pet"
}
]
}
}
}
}
Resolved Schema has additionalProperties as null, where properties is resolved correctly. I believe that ResolverFully.aggregateSchemaCombinators method does not handle additionalProperties like it handles properties. In order to solve this issue, I added the following code before the line Map<String, Schema> properties = resolved.getProperties(); in aggregateSchemaCombinators method, knowing that it is not the perfect fix that handles all of the scenarios:
It solved my issue, but probably it may not work in a more complex structure. Do you have any suggestions?
When I try to test these two OpenAPI documents from https://editor.swagger.io/ I can see both properties and additionalProperties in both files are resolved correctly. Example Value:
I am using swagger-parser 2.1.25 and when I parse an OpenAPI document openapi-properties-additionalProperties.json using these ParseOptions:
It works perfect without any issues. swagger-parser can parse both
properties
andadditionalProperties
. However, when I change therequestBody
structure fromto
as in openapi-allOf-properties-additionalProperties.json, where
Pet
schema has bothproperties
andadditionalProperties
like this in both documents:Resolved
Schema
hasadditionalProperties
asnull
, whereproperties
is resolved correctly. I believe thatResolverFully.aggregateSchemaCombinators
method does not handleadditionalProperties
like it handlesproperties
. In order to solve this issue, I added the following code before the lineMap<String, Schema> properties = resolved.getProperties();
inaggregateSchemaCombinators
method, knowing that it is not the perfect fix that handles all of the scenarios:targetSchema.setAdditionalProperties(resolved.getAdditionalProperties());
It solved my issue, but probably it may not work in a more complex structure. Do you have any suggestions?
When I try to test these two OpenAPI documents from https://editor.swagger.io/ I can see both
properties
andadditionalProperties
in both files are resolved correctly. Example Value:The text was updated successfully, but these errors were encountered: