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

Can this library integrate openapi #17

Open
suoaao opened this issue Dec 3, 2020 · 6 comments
Open

Can this library integrate openapi #17

suoaao opened this issue Dec 3, 2020 · 6 comments

Comments

@suoaao
Copy link

suoaao commented Dec 3, 2020

In this way

@app.route("/kwargs")
@validate()
def test_route_kwargs(query:Query, body:Body)->MyModel:
    return MyModel(...)

In : test_route_kwargs.__annotations__
Out:
{'query': Query,
' body':Body,
 'return': MyModel}

It can get all the conditions for generating openapi.

@bauerji
Copy link
Owner

bauerji commented Dec 3, 2020

Hi,

Do you mean to automatically generate route serving openapi documentation of all routes? This is actually a good idea. I will try to find time to implement it.

Jirka

@miquelvir
Copy link

I agree with @crowser ! I wanted to use this for a project, only drawback: no auto generated docs. This module could be the perfect reason to stay with all the benefeits of Flask + many of Fastapi.

Pydantic models can be transformed to compliant schemas out of the box (https://pydantic-docs.helpmanual.io/usage/schema/). So the only thing is generating the docs for each view/function, and then providing a swagger.json endpoint. Optionally, we could have out of the box a /redoc and /swagger endpoints with the doc ui.

@miquelvir
Copy link

@bauerji I have a working prototype, but I needed to convert Flask Pydantic to a proper flask extension. Have you worked on this?

@bauerji
Copy link
Owner

bauerji commented Apr 12, 2021

@miquelvir I have though about it but haven't worked on it yet. Could you share me please your solution? I don't think it is necessary to convert it to flask extension. I don't want to make such a backward incompatible change.

@miquelvir
Copy link

@bauerji I needed to convert it to a Flask extension, how would you do it without? i will share when ive got a moment

@bauerji
Copy link
Owner

bauerji commented Apr 12, 2021

@miquelvir I can imagine you might need it for list of routes but that can be stored in validate decorator. For adding docs routes too maybe, but that can be overcome by passing application as function parameter. Do you have any other reason for it?

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

3 participants