-
Notifications
You must be signed in to change notification settings - Fork 3
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
DM-37525: Add openapi generator extension #159
Conversation
This Sphinx extension can run a user-provided function to generate the OpenAPI specification for, e.g., a FastAPI project.
- Include sphinxcontrib-redoc to the [guide] extras - In the default configuration for guides, include sphinxcontrib-redoc and documenteer.ext.openapi.
The new [project.openapi] section lets docs writers configure both documenteer.ext.openapi and sphinxcontrib-redoc to generate and include redoc docs in their site.
Add both the TOML reference for [project.openapi] and a guide for setting up the Redoc/OpenAPI site embed.
569788e
to
9efb7c7
Compare
Setting the default to None makes the documenteer.toml use case easier so that the value can be set to None if the [project.openapi] table isn't set. Otherwise Sphinx raises a value that None is being set on a string-defaulted configuration.
9efb7c7
to
c15d756
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Really happy with how easy this is to plug in to packages.
The demo with squarebot for some reason didn't work for me. I just see the stub page when I go to https://squarebot.lsst.io/v/DM-37525/api.html, I just see the stub page.
Whoops, looks like I broke it. I'll check this. |
https://squarebot.lsst.io/v/DM-37525/api.html is working again. I'm still not sure why the stub didn't get replaced; I haven't been able to replicate it. |
This PR provides support for embedding a Redoc site for FastAPI apps and other projects that have OpenAPI specifications.
documenteer.ext.openapi
Sphinx extension can generate the OpenAPI specification during the Sphinx build by running a user-specified function. See the docs at https://documenteer.lsst.io/v/DM-37525/sphinx-extensions/openapi.htmldocumenteer.ext.openapi
andsphinxcontrib.redoc
extensions are included by default with the Documenteer user guide configuration (documenteer[guide]
)[project.openapi]
table in thedocumenteer.toml
configuration file. See the docs at https://documenteer.lsst.io/v/DM-37525/guides/openapi.htmlsphinxcontrib.redoc
extension. This solution removes the need to an API landing page.For a working demo see lsst-sqre/squarebot#18 and https://squarebot.lsst.io/v/DM-37525/index.html