openapi-spec-validator icon indicating copy to clipboard operation
openapi-spec-validator copied to clipboard

Validator doesn't work with custom server url

Open sjiekak opened this issue 5 years ago • 0 comments

We are running a pyramid app with the following open api yaml definition :

openapi: 3.0.1
info:
  title: Sample API
  contact:
    name: API Support
    email: [email protected]
  version: 1.0.0
  x-audience: external-public
  description: |
    # Minimum 

servers:
  - url: https://client.public.api.com/
    description: Production Server
paths:
  /test:
    get:
      summary: "test path"
      operationId: my.app.function
      responses:
        200:
          description: will always return ok

Requests to the endpoint /test will fail with Server not found for http://0.0.0.0:8080/test unless the default server is added to the servers object:

servers:
  - url: https://some.private.api.com/
    description: Production Server
  - url: /
    description: Validation URL

it seems the url validator try to resolve the url in the servers field.

https://github.com/p1c2u/openapi-spec-validator/blob/master/openapi_spec_validator/handlers.py#L25

The validator should use the default server url as a fallback if the provided url can't be resolved. I would like to avoid displaying the Validation URL to the api user.

note : first version incorrectly assumed a query was made on the url.

sjiekak avatar Jun 02 '20 10:06 sjiekak