Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

OpenAPI servers not auto-generated when root_path is set #454

Open
duckontheweb opened this issue Aug 19, 2022 · 0 comments
Open

OpenAPI servers not auto-generated when root_path is set #454

duckontheweb opened this issue Aug 19, 2022 · 0 comments

Comments

@duckontheweb
Copy link
Contributor

As of fastapi/fastapi#1596 FastAPI will autogenerate the servers section of the OpenAPI document if the FastAPI instance has a root_path set. This is crucial in setting up the right routes in things like the "Try it out" section of the Swagger docs page.
Because stac-fastapi customizes the FastAPI.openapi method and does not pass the servers argument through, this section of the docs does not get autogenerated as it should.

The signature of StacAPI.customize_openapi should probably be updated to pass through all of the same arguments as the default FastAPI.openapi method.

def openapi(self) -> Dict[str, Any]:
    if not self.app.openapi_schema:
        self.openapi_schema = get_openapi(
            title=self.title,
            version=self.api_version,
            openapi_version=self.app.openapi_version,
            description=self.description,
            terms_of_service=self.app.terms_of_service,
            contact=self.app.contact,
            license_info=self.app.license_info,
            routes=self.app.routes,
            tags=self.app.openapi_tags,
            servers=self.app.servers,
        )
    return self.app.openapi_schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant