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

Unable to parse non-str example values #54

Open
fralik opened this issue Nov 29, 2021 · 0 comments
Open

Unable to parse non-str example values #54

fralik opened this issue Nov 29, 2021 · 0 comments

Comments

@fralik
Copy link

fralik commented Nov 29, 2021

Parameter examples are not necessary strings. However, the code in paths.py assumes that they are. Consider this file for validation:

openapi: 3.0.1
info:
  title: Example type bug
  version: v1.0
servers:
  - url: https://api.example.com/v1.0/
    description: Core

paths:
  /users/{id}:
    get:
      summary: Get user
      parameters:
        - name: id
          in: path
          required: true
          description: ID of a user
          schema:
            minimum: 0
            type: integer
          example: 50
      responses:
        '200':
          description: Retrieved user
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string

Code

from openapi3 import OpenAPI
import yaml

with open('openapi.yaml') as f:
    spec = yaml.safe_load(f.read())

api = OpenAPI(spec)

produces the error message:
openapi3.errors.SpecError: Expected paths./users/{id}.get.parameters.0.example to be one of [<class 'str'>], got <class 'int'>

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