Open ManuAc opened 5 years ago
Does commons.yaml
contain the root definitions
node? If not, the $refs should look like this:
$ref: 'https://example.com/commons.yaml#/StatusUpdateRequest'
$ref: 'https://example.com/commons.yaml#/Status'
Does
commons.yaml
contain the rootdefinitions
node? If not, the $refs should look like this:$ref: 'https://example.com/commons.yaml#/StatusUpdateRequest' $ref: 'https://example.com/commons.yaml#/Status'
Hey @hkosova,
Yes commons.yaml does contain root definitions node
Description
We are using swagger codegen maven plugin to generate models and API clients.
We have a single YAML file for defining all common models and refer them using UR as and when required from all other services. The problem is swagger won't resolve the nested models automatically and it expects all nested models to be defined in the same file (we can reference the remote definition here also but defining the models itself become tedious when there is deep nesting).
Is there any workaround for the same? Can we do something to just reference the root level definition and swagger will automatically resolve all other nested references?
Swagger-codegen version
2.1.6
Swagger declaration file content or url
Example
common.yaml
Let's say my common.yaml is available at https://example.com/commons.yaml, then my individual service level yaml will be like below
ServiceA.yaml
But above will fail because swagger won't automatically resolve nested Status definition. We'll have to define Status also in ServiceA.yaml.
Below will work.
Suggest a fix/enhancement
I think codegen should automatically resolve all nested references. We can use various rules while doing so. For example, if someone wants to refer a model at different location for a nested model, they can explicitly define that along with root-level model definition.