pyramid_openapi3 icon indicating copy to clipboard operation
pyramid_openapi3 copied to clipboard

server url and routes autogeneration

Open mattiaverga opened this issue 3 years ago • 1 comments

I can't found an example that covers my case, so it may be me doing something wrong.

I've put this in pyramid config:

config.include("pyramid_openapi3")
config.pyramid_openapi3_spec_directory(
    os.path.join(os.path.dirname(__file__), 'openapi', 'openapi.yaml'), route='/api/v2/spec')
config.pyramid_openapi3_add_explorer(route='/api/v2')

config.pyramid_openapi3_register_routes()

and in openapi.yaml file I have:

servers:
  - url: /api

paths:
  /v2/users/:
    x-pyramid-route-name: users_api_v2

I get a 404 Page Not Found for /api/v2/users/, while /v2/users/ works (but doesn't validate against the server, obviously). To make things work I have to set the server as just / and move api to the path. Is that how it is supposed to work, or route autogeneration doesn't work right?

mattiaverga avatar Dec 12 '22 17:12 mattiaverga

The test does not set servers, so it is entirely possible that there is a bug. Can you try changing this test to set servers and see if it fails?

zupo avatar Dec 12 '22 20:12 zupo