OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I am using bundled code from swagger cli. In my case, the bundler is putting $ref to Schemas that are a few levels deep into response and requestBodies (i.e. properties of objects that are properties of object...etc.). Currently, in the default generator, the models are gathered by this call:
''' java
final Map<String, Schema> schemas = ModelUtils.getSchemas(this.openAPI);
'''
which, in the javadocs, is stated the following:
'''java
/**
Return a Map of the schemas defined under /components/schemas in the OAS
document. The returned Map only includes the direct children of
/components/schemas in the OAS document; the Map does not include inlined
schemas.
@param openAPI the OpenAPI document.
@return a map of schemas in the OAS document.
*/
'''
So the problem is that there is never a search for second level+ models. This cause a few issues, namely, that any model that references these other models will resolve them to Object. The correct thing that should be done here is that all models should be included. There is even a function right below this one that returns all Schemas, however it does it in list form.
In my local clone, I have added a function to "true up" the schemas above by looking for all schemas and then adding the new ones to the map. Later, everything seems to work correctly, especially when I have fixed the path walking issue in #7400. However, this seems like a separate issue, so I am filing it separately.
All of my work has been based off of v4.3.1. I can create a PR upon request, but I am not sure if my solution is the correct one for the maintainers.
Bug Report Checklist
Description
I am using bundled code from swagger cli. In my case, the bundler is putting $ref to Schemas that are a few levels deep into response and requestBodies (i.e. properties of objects that are properties of object...etc.). Currently, in the default generator, the models are gathered by this call:
''' java final Map<String, Schema> schemas = ModelUtils.getSchemas(this.openAPI); '''
which, in the javadocs, is stated the following:
'''java /**
In my local clone, I have added a function to "true up" the schemas above by looking for all schemas and then adding the new ones to the map. Later, everything seems to work correctly, especially when I have fixed the path walking issue in #7400. However, this seems like a separate issue, so I am filing it separately.
All of my work has been based off of v4.3.1. I can create a PR upon request, but I am not sure if my solution is the correct one for the maintainers.