-
Notifications
You must be signed in to change notification settings - Fork 536
Properties being ignored on schemas containing allOf #1143
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
Comments
@damapin Does it work if you structure your definition like this?
|
you need the - in front of properties` |
@garcle no, that is incorrect. That would be an allOf list of 3 separate things - i) the $ref, ii) type: object, and iii) an isolated list of properties. |
I have exactly the same issue with Azure model from https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/redis/resource-manager/Microsoft.Cache/stable/2018-03-01/redis.json For example, RedisResource contains properties and allOf
Using swagger-codegen that uses swagger-parser results in RedisResource missing all of it's properties except the ones inherited from definitions/TrackedResource. Note: in case of RedisResource, there is a property that is actually called "properties" - this is just the name of that property, do not let that confuse you. Also if I use this model in Swagger UI at swagger.io - the model is generated correctly for Swagger UI: |
This is .md file generated for RedisResource by swagger-codegen (that uses swagger-parser):
All those properties are inherited from TrackedResource. Same issue in generated code. There is a clear difference here between Swagger UI and swagger-codegen (and thus swagger-parser) results, and it seems to be pretty clear that swagger-parser has a bug of ignoring "properties" section for any model having "allOf". |
…operties in ComposedModel
refs swagger-api/swagger-parser#1143 - pull up model properties and required
refs - issue #1143 - changes to support properties in ComposedModel
refs - issue #1143 - changes in converter to support properties in Composed Model
fixed in #1240, #1241 and swagger-api/swagger-codegen#9827 |
Hello.
I'm trying to parse a swagger file which is converted to OpenApi object. It seems to run properly, but when I try to extract properties from complex schemas that use allOf then the properties that are not included in the referenced schema are ignored.
For instance, I have this definition of a request body parameter:
The referenced definition looks like this:
Thus I intend to keep all the properties of identificacion_usuario and add a new aplicacion property to the request body. The problem is that this new property is not parsed by the swagger converter. When I call
I get an OpenApi object that seems to be ok, but it's not. After inspecting the OpenApi object I found that components->schemas had a LinkedHashMapEntry with key identificacion_usuario_aplicacion that had as value a ComposedSchema with an allOf Schema set. But, unfortunately, ComposedSchema properties were set to null.
Taking a deep dive into the libraries I think the issue comes from io.swagger.parser.util SwaggerDeserializer.Class contained on swagger-parser-1.0.45.jar. The definition method, lines 771 to 773, calls to allOfModel method:
allOfModel method, contained in the same class, receives an object node which contains two children nodes: allOf and properties. The properties child node is ignored in this method, which processes and returns only the allOf child node.
I think the problem is there, but I'm not completely sure of it. And also I'm not completely sure about the way to fix it.
Could you please review the issue.
Thank you very much.
The text was updated successfully, but these errors were encountered: