Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Support For Not Enabling Spec View #208

Open
zach-hamm opened this issue Apr 20, 2023 · 8 comments
Open

Add Support For Not Enabling Spec View #208

zach-hamm opened this issue Apr 20, 2023 · 8 comments
Labels
question Further information is requested

Comments

@zach-hamm
Copy link

I was hoping to update the config.pyramid_openapi3_spec directive so that it registers the spec file to the library, but doesn't enable the route/view. The reason being is we need to perform some filtering on our spec file to determine if you have access to see all of the contents or not. Alternatively, there could be another way to just register the spec file without creating a view for it like:

config.pyramid_openapi3_register_spec

@zupo
Copy link
Collaborator

zupo commented Apr 20, 2023

Routes and views are not registered by config.pyramid_openapi3_spec, one has to call pyramid_openapi3_register_routes to register routes. Views are always registered by the user.

So I'm not sure what the problem is, can you provide more detail?

@zach-hamm
Copy link
Author

A route and view is added when you register your spec which you can see here:

config.add_route(route_name, route)

By default a view is added and you can see the spec file. I had to disable it by committing the config and adding my own afterwards, but it would be nice if it was optional by the library. If there’s a different way to setup the library without creating a view let me know. I poked around and didn’t see anything so I followed what was in the README

@zupo
Copy link
Collaborator

zupo commented Apr 20, 2023

Ahhh, now I see, you mean the route/view for the Swagger UI, I thought you meant the routes/views for endpoint defined in openapi.yaml file.

If you wanna contribute this feature, having config.pyramid_openapi3_spec(swagger_ui=False) seems like the cleanest way to do it in my eyes.

@zach-hamm
Copy link
Author

No that’s for the OpenAPI yaml file. The swagger UI registration has its own endpoint which is here:

def add_explorer_view(

The link I sent previously creates a route/view for the YAML file which you can see here:

def spec_view(request: Request) -> FileResponse:

It’s generating a new view where the YAML file is the response.

@zupo
Copy link
Collaborator

zupo commented Apr 20, 2023

Ah, yes, you are correct, long day here, sorry.

@zach-hamm
Copy link
Author

All good! I’ve been out on vacation, but I don’t mind making these changes when I get back and opening up a PR for them if that sounds like a good idea to you.

@zupo
Copy link
Collaborator

zupo commented Apr 27, 2023

A register_view=True default flag for add_spec_view sounds reasonable.

@zupo
Copy link
Collaborator

zupo commented Mar 7, 2024

Hey @zach-hamm, do you want to keep working on this, or should I close the issue?

@miketheman miketheman added the question Further information is requested label Mar 11, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants