Description
Hi there, new to FastAPI so sorry if this question has been asked elsewhere:
What is the best way to enrich the auto-generated OpenAPI-Spec generated by FastAPI. It currently seems to support only a few things (like changing the title or description), but if I would want to add tags to group my endpoints or do sth more fancy like adding a logo (which is supported by ReDoc via x-logo) it seems to me that I would want to use FastAPI to generate the base specification and then add some scripts that will enrich this spec in a structured way?
Has anyone encountered this issue before?
Additional context
I already looked into the code a little bit and it seems that the ReDoc that gets shown when serving the API is generated on the fly (as is the OpenAPI schema) => this seems to make a custom processing of the specification to make use of cool ReDoc features harder
and yes it's generated on the fly. the documentation is very well written, you should take a look :hibiscus:
great thanks for the pointer :)
it seems to me that I would want to use FastAPI to generate the base specification and then add some scripts that will enrich this spec in a structured way?
re-reading you it seems like you somehow missed the part with pydantic models (https://fastapi.tiangolo.com/tutorial/body-nested-models/)
the models you define will be documented in the schema if you prefer
no, where my question came from is that there are all these cool Redoc vendor extensions (like x-logo) that I currently have in my OpenAPI spec (with flask as a backend) => I would ideally like to move this to FastAPI soon, but I don't really expect you guys to support all of those vendor extensions out of the box and was thinking I would need to somehow write my own scripts that enrich the generated OpenAPI spec with the vendor extensions I want and wasn't sure how to best integrate this with FastAPI. Does this make sense?
All the path operation configuration you pointed me to definitely already help (but does not fix the problem with the vendor extensions) :)
https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md
x-TagGroups is another one I really like for example
maybe it would make sense to add support for vendor extensions in general somehow? (s.t. that I can enrich the OpenAPI spec with whatever I like and if ReDoc happens to use that vendor extension: lucky me!)
Seems like a post-processing hook for creating the openapi spec would be handy for this. That way custom processing could happen after the fastAPI spec generation happens and before it's presented to Swagger UI or ReDoc.
Thanks for the help here @euri10 and @wshayes !
So, I just ended up adding it to the docs. Exactly with your ReDoc logo example :smile: https://fastapi.tiangolo.com/tutorial/extending-openapi/ :tada:
Awesome, thanks!
Great! Thanks for coming back and closing it.
Thanks for the help here @euri10 and @wshayes !
So, I just ended up adding it to the docs. Exactly with your ReDoc logo example 馃槃 https://fastapi.tiangolo.com/tutorial/extending-openapi/ 馃帀
move to https://fastapi.tiangolo.com/advanced/extending-openapi/
Most helpful comment
move to https://fastapi.tiangolo.com/advanced/extending-openapi/