A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/OpenAPITools/openapi-generator/issues/1714 below:

[BUG] $ref to common parameter not being resolved · Issue #1714 · OpenAPITools/openapi-generator · GitHub

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4