luolingchun / flask-openapi3

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

Question: Use of components / references / parameters #192

Closed brownterryn closed 1 week ago

brownterryn commented 3 weeks ago

Looking at switching from flasgger to flask-openapi3

The way I have things set up using flasgger (with @swag_from to read yaml specs.) I can generate an OpenAPI spec. which uses components/parameters and references, so an endpoint's spec. might look like:

example JSON endpoint spec. ```json "/some-api/api/v4/chemNN/": { "get": { "description": "Get nearest neighbors for chem. with FP", "responses": { "200": { "description": "Nearest neighbors and FP or chem." } }, "parameters": [ {"$ref": "#/components/parameters/chem_id"}, {"$ref": "#/components/parameters/fp"}, {"$ref": "#/components/parameters/fp_weight"}, {"$ref": "#/components/parameters/sel_by"}, {"$ref": "#/components/parameters/k0"} ], "tags": [ "domain" ] } } ```

Can flask-openapi3 generate output like that? I see the Components and Parameters models, but not sure how to use them.

luolingchun commented 1 week ago

flask-openapi3 doesn't use an explicit spec like flasgger, which you can get using http://127.0.0.1:5000/openapi/openapi.json.

More information see the Specification.