-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
When parsing a swagger file during codegen, almost all references are resolved - i.e. when producing the input file for a mustache template, the referenced YAML is inserted into the referring object.
However, this isn't happening for vendor extensions, meaning that I can't generate the docs & stubs that I need.
Swagger-codegen version
Master (as of 2017-01-09 ~09:30 UTC, i.e. 81b5b78).
Swagger declaration file content or url
At the top level of the YAML spec, there are some vendor extensions. (In this case, they define common error information, used in several places throughout the rest of the API.)
x-error-defs:
credentialTooShort:
errorID: credentialTooShort
message: Credential %1 is shorter than the minimum allowed (%2).
variables:
- The credential field which is too short.
- The minimum permitted credential length.
credentialTooLong:
errorID: credentialTooLong
message: Credential %1 is longer than the maximum allowed (%2).
variables:
- The credential field which is too long.
- The maximum permitted credential length.Within a particular response to an operation, there is a vendor extension with references to the top-level extensions. (In this case, error response objects refer to particular errors that might be returned from the operation.)
'400':
description: |
The account could not be created because a credential didn't meet the complexity requirements.
schema:
$ref: './shared/error.yaml#/error'
x-error-refs:
- '$ref': '#/x-error-defs/credentialTooShort'
- '$ref': '#/x-error-defs/credentialTooLong'Command line used for generation
java -DdebugOperations -jar ../../../swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i credentials.yaml -l html2
Steps to reproduce
Generate API docs using the command line above for a Swagger spec. containing the YAML fragments above. Reproduces 100% of the time.
Related issues
Until yesterday, vendor extensions in responses didn't work at all. This was fixed under #4022, in so far as the extensions do now appear in the mustache input file - it's just that the references aren't being resolved.
Suggest a Fix
Fully resolve references in vendor extensions, just like in other places (e.g. parameters).