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

Generate the openapi_schema for a specific api version using the app.openapi() method #62

Open
ddoren opened this issue Nov 13, 2021 · 0 comments

Comments

@ddoren
Copy link

ddoren commented Nov 13, 2021

Is your feature request related to a problem? Please describe.
Hey, I'm trying to generate the full openapi.json file for a specific API version without running the server, programmatically, as I need to generate the html documentation from it. Is there a way to do that? using the app.openapi() would hide the endpoints behind the versions.
But I need the openapi schema for a specific API version.

Describe the solution you'd like
A method that would allow the generation of a specific versioned openapi schema, something like app.openapi('v1') or anything would work really.

Additional context

from fastapi.openapi.utils import get_openapi
from app import app
import json


with open("openapi.json", "w") as file:
    json.dump(app.openapi(), file)


with open("openapi-get.json", "w") as file:
    openapi_schema = get_openapi(
        title="Custom title",
        version="2.5.0",
        description="This is a very custom OpenAPI schema",
        routes=app.routes,
    )

The generated openapi schema includes the v0 and v1 endpoints, however need a method to generate the schema with the endpoints for a specific version.

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