Fastapi: [QUESTION] Does it exists a swagger to pydantic models ?

Created on 14 Oct 2019  路  5Comments  路  Source: tiangolo/fastapi

Description
I'm looking for a tool that could generate pydantic's models from swagger/openai yaml/json ?
It should exists, no ?

question

Most helpful comment

Sorry, the code generator doesn't support swagger(v2) :(
I recommend converting swagger(v2) to openapi(v3).

If a lot of people request to support swagger(v2) then, We will implement it. 馃槃

All 5 comments

I develop code generator for pydantic model from openapi yaml/json.
https://github.com/koxudaxi/datamodel-code-generator

Also, Our company uses the code generator for the production api server.

If you have a request, suggest then, Welcome Any feedback, PR.

I've tested ^^
But it doesn't seem to work for my swagger (v2) ;-(
I don't have time to explore why (miss key "components" during process)

Sorry, the code generator doesn't support swagger(v2) :(
I recommend converting swagger(v2) to openapi(v3).

If a lot of people request to support swagger(v2) then, We will implement it. 馃槃

@manatlan you can also search for a tool to convert from Swagger v2 to OpenAPI (Swagger) v3. And then use @koxudaxi's code generator with that.

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

Was this page helpful?
0 / 5 - 0 ratings