Skip to content

Unresolvable JSON pointer when references are used together with default values #98

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

Closed
bushkov opened this issue Sep 7, 2020 · 1 comment

Comments

@bushkov
Copy link

bushkov commented Sep 7, 2020

  • OpenAPI Spec validator version: 0.2.9
  • Python version: 3.7.7
  • Operating system: macOS Catalina 10.15.6

For complex OpenAPI types openapi-spec-validator fails when those types have a #ref reference and a default value specified.

Steps to reproduce the problem

For example, if I have the following cats_fail.yaml file:

openapi: 3.0.1
info:
  title: Cat API
  version: 2.0.0
paths:
  /yodeling:
    post:
      requestBody:
        description: Cats yodeling payload
        content: 
          'application/json':
            schema:
              $ref: '#/components/schemas/catsRequest'
      responses:
        '200':
          description: cats yodeling success
components:
  schemas:
    catsRequest:
      type: object
      properties:
        name:
          $ref: "#/components/schemas/catName"
      default: {
        "name": "schrodinger"
      }
    
    catName:
      type: string

then running the following command:

openapi-spec-validator cats_fail.yaml

results in the following error message:

Unresolvable JSON pointer: 'components/schemas/catName'

However, for the following cats_success.yaml file:

openapi: 3.0.1
info:
  title: Cat API
  version: 2.0.0
paths:
  /yodeling:
    post:
      requestBody:
        description: Cats yodeling payload
        content: 
          'application/json':
            schema:
              $ref: '#/components/schemas/catsRequest'
      responses:
        '200':
          description: cats yodeling success
components:
  schemas:
    catsRequest:
      type: object
      properties:
        name:
          type: string
      default: {
        "name": "schrodinger"
      }

running:

openapi-spec-validator cats_success.yaml

results in OK response.

@hlobit
Copy link
Contributor

hlobit commented Sep 21, 2020

Looks like it's the same issue I reported on #92.

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

3 participants