-
- Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Description
Description
Validation is failing to resolve a $ref
in the parameter list to a common parameter defined outside the operation. Neither refs local to the same file nor refs to external files work. Both should. I've tried it with both Swagger 2.0 and OAS 3.0 specs, both fail the same way.
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI). | Error count: 1, Warning count: 0 Errors: -attribute paths.'/employees/{id}'. Declared path parameter id needs to be defined as a path parameter in path or operation level at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:569) at org.openapitools.codegen.cmd.Generate.run(Generate.java:346) at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:62)
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.0 info: title: Test description: Test YAML version: '1.0' servers: - url: http://localhost paths: /employees/{id}: get: operationId: getEmployeeById parameters: - $ref: '#/components/parameters/id' responses: 200: description: Success content: application/json: schema: $ref: '#/components/schemas/employee' components: schemas: employee: type: object properties: name: type: string required: - name parameters: id: name: id in: path required: true schema: type: string
Command line used for generation
java -jar openapi-generator-cli-4.0.0-20181217.102953-101.jar generate -g html -i test.yaml
Related issues/PRs
#455 seems to be related. But that one was resolved. So that makes this a regression.
Suggest a fix
This could be another issue with the swagger-parser
like in #455.
timonbimon, tomghyselinck, caturner81, philcluff, jimschubert and 5 more