Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolveFully breaks 3.0 spec for headers via $ref in request and response #2060

Open
david0 opened this issue Feb 26, 2024 · 0 comments
Open

Comments

@david0
Copy link

david0 commented Feb 26, 2024

Given the following files:

openapi: 3.0.3
info:
  title: Sample API
  version: 1.0.0
paths:
  /users/:
    get:
      parameters:
        - $ref: 'headers.yml#/XRequestId'
      responses:
        '200':
          description: Ok
          headers:
            X-Request-Id:
              $ref: 'headers.yml#/XRequestId'

and

XRequestId:
  in: header
  name: X-Request-Id
  schema:
    type: string
  required: false
		OpenAPIV3Parser parser = new OpenAPIV3Parser();
		ParseOptions options = new ParseOptions();
		options.setResolveFully(true);

		var api = parser.read(file, null, options);
		String content = Yaml.pretty(api);

the output will contain a $ref that cannot be resolved:

openapi: 3.0.3
info:
  title: Sample API
  version: 1.0.0
servers:
- url: /
paths:
  /users/:
    get:
      parameters:
      - name: X-Request-Id
        in: header
        required: false
        schema:
          type: string
      responses:
        "200":
          description: Ok
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
components:
  parameters:
    XRequestId:
      name: X-Request-Id
      in: header
      required: false
      schema:
        type: string

I know the in: is not valid for responses, but swagger-ui seems to be fine with it.

Surprisingly using version: 3.1.0 fixes that thing, unfortunately openapi-generator is not yet ready for that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant