Content-Length: 285548 | pFad | http://github.com/python-openapi/openapi-spec-validator/issues/160

5C No specific error information available. · Issue #160 · python-openapi/openapi-spec-validator · GitHub
Skip to content

No specific error information available. #160

Open
@WillFreitag

Description

@WillFreitag

First of all, I'm focussing on validating models (components/schemas) in an OpenAPI 3.0.0. yaml file.
I'm testing with a slightly changed petstore.yaml (keep an eye on components/schemas/Pet/properties/id which has an extra attribute min instead of minimal):

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          schema:
            type: integer
            format: int32
      responses:
        200:
          description: An paged array of pets
          headers:
            x-next:
              description: A link to the next page of responses
              schema:
                type: string
          content:
            application/json:    
              schema:
                $ref: "#/components/schemas/Pets"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    post:
      summary: Create a pet
      operationId: createPets
      tags:
        - pets
      responses:
        '201':
          description: Null response
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /pets/{petId}:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          schema:
            type: string
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pets"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id:
          min: 1
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
        $ref:
          type: string
    Pets:
      type: array
      items:
        $ref: "#/components/schemas/Pet"
    Error:
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string

Swagger Editor reports nicely on that little "typo" in pet's property id:

grafik

No matter what I try with openapi-spec-validator, it reqognizes an error like that from above but the error (OpenAPIValidationError or iterator) is totally unspecific.

Validating the above yaml with:

  try:
      spec_dict, spec_url = read_from_filename('model.yaml')
      validate_v30_spec(spec_dict)
  except IOError as e:
      print(e)
  except OpenAPIValidationError as e:
      print(e)

...gives an output like:

{'description': 'An paged array of pets', 'headers': {'x-next': {'description': 'A link to the next page of responses', 'schema': {'type': 'string'}}}, 'content': {'application/json': {'schema': {'$ref': '#/components/schemas/Pets', 'x-scope': ['']}}}} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['responses']['patternProperties']['^[1-5](?:\\d{2}|XX)$']:
    {'oneOf': [{'$ref': '#/definitions/Response'},
               {'$ref': '#/definitions/Reference'}]}

On instance['paths']['/pets']['get']['responses']['200']:
    {'content': {'application/json': {'schema': {'$ref': '#/components/schemas/Pets',
                                                 'x-scope': ['']}}},
     'description': 'An paged array of pets',
     'headers': {'x-next': {'description': 'A link to the next page of '
                                           'responses',
                            'schema': {'type': 'string'}}}}

No hint on that specific error ("additionalProperty in pet.id" or something like that).

Is openapi-spec-validator not what I'm looking for?
Do I use this validator in a wrong way?
Do I miss anything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/python-openapi/openapi-spec-validator/issues/160

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy