alexschimpf / fastapi-versionizer

FastAPI Versionizer
MIT License
81 stars 13 forks source link

Versionized docs are not showing "servers" unless the base /docs is visited 1st #62

Open jobewan opened 5 months ago

jobewan commented 5 months ago

Subject of the issue

Versionized docs are not showing "servers" and swagger api executions return 404 unless the base /docs is visited 1st

Your environment

Steps to reproduce

Run the with_root_path.py example, visit the versionized docs and execute an api call or pull the openapi schema json file

Expected behaviour

The servers should be populated in the versionized openapi shcema and the swagger executions should work

Actual behaviour

This is odd. When using the example with_root_path.py. While using the options: "include_main_docs=False, include_main_openapi_route=False", the versionized docs @ /root/path/api/v[1,2]/docs results in every swagger api execution to return a 404 due to it not using the root path (the api "servers" are not populated in the openapi schema file either). Although, if you change the parameters so that "include_main_docs=True, include_main_openapi_route=True", you can visit the /root/path/docs to see things working as expected, and THEN visit the /root/path/api/v[1,2]/docs paths and those versions work as expected by populating the "servers" param in the schema and the swagger api executions work.

alexschimpf commented 5 months ago

@jobewan And just to be clear, which version of fastapi are you using?

jobewan commented 4 months ago

fastapi version: 0.106.0