luolingchun / flask-openapi3

Generate REST API and OpenAPI documentation for your Flask project.
https://luolingchun.github.io/flask-openapi3/
MIT License
186 stars 28 forks source link

Manual registration of custom component schemas without route definition #181

Open marcuslary opened 3 days ago

marcuslary commented 3 days ago

I'm looking for a way to manually register a component schema by providing a pydantic dto without using a route definition. Searched and played around a bit, but couldn't figure out how to do it. Is this supported in any way by the library? Thanks :-)

luolingchun commented 2 days ago

The OpenAPI class defines two global variables self.components_schemas and self.spec_json.

All the model schemas are stored self.components_schemas and the final specification documents are stored self.spec_json.

I think you can manually update these two variables to achieve your needs.