litestar-org / pydantic-openapi-schema Goto Github PK
View Code? Open in Web Editor NEWGenerate OpenAPI 3.x.x using Pydantic
Home Page: https://starlite-api.github.io/pydantic-openapi-schema/
License: MIT License
Generate OpenAPI 3.x.x using Pydantic
Home Page: https://starlite-api.github.io/pydantic-openapi-schema/
License: MIT License
the tags
key under Schema
is currently typed as Optional[List[str]]
, but it should actually be Optional[List[Tag]]
I use a pydantic model to serialize some data and return as a response. Some fields have alias.
The problem is that OpenAPI310PydanticSchema
always returns property names taken from alias, while default is False. So there's a mismatch between the actual output and OpenAPI310PydanticSchema when by_alias is False (default)
There is a logic in description, that param_in
attribute affects style
attribute (see docstring under attr):
https://github.com/starlite-api/pydantic-openapi-schema/blob/7273555abe0d2255f8cfa657a785149c65f2812e/pydantic_openapi_schema/v3_1_0/parameter.py#L71
Also, there is a logic in description, that style
attribute affects explode
attribute:
https://github.com/starlite-api/pydantic-openapi-schema/blob/7273555abe0d2255f8cfa657a785149c65f2812e/pydantic_openapi_schema/v3_1_0/parameter.py#L81
But as I can see, it is just a description, and actually all these attributes don't affect each other. This is why Starlite has some issues with OpenAPI integration (e.g. litestar-org/litestar#1033).
Should we modify the building of OpenAPI parameters and how to resolve all listed dependencies (E.g. param_in=query
=> style=form
=> explode=True
) in this repo. Or we should manage listed dependencies in Starlite?
This will allow us to import the inventory into the starlite reference docs and cross reference to these docs.
See https://mkdocstrings.github.io/usage/#cross-references-to-other-projects-inventories
In Python 3.11
inspect.Parameter
raises ValueError
where a parameter name is a keyword (see python/cpython#92062).
We at least have Schema
that triggers this error due to pydantic trying to create the aliases as parameters for the model signature, but there might be more too.
class Schema(BaseModel):
schema_not: Optional[Union[Reference, "Schema"]] = Field(default=None, alias="not")
schema_if: Optional[Union[Reference, "Schema"]] = Field(default=None, alias="if")
PR that resolves from the pydantic end is merged and available in the 1.10 pre-releases: pydantic/pydantic#4012.
I suppose we'll need a minimum 1.10 version constraint for pydantic based on the python version >=3.11
We should add a CONTRIBUTING.md and link it in the readme properly.
Starlite assumes a minimum of 3.1.0, so keeping 3.0.3 models isn't really worth the maintenance burden.
E.g. I want to add a pydantic nested model to an openapi dict.
Right now I do something like, for sure there's a better way. README and docs should have a proper example.
schema["components"]["schemas"][
"POSTMultipartParameters"
] = w2s.POSTMultipartParameters.schema()
schema["components"]["schemas"]["POSTMultipartParameters"]["properties"]["file"].update(
type="string", format="binary"
)
schema["components"]["schemas"]["W2"] = w2s.W2.schema()
schema["components"]["schemas"]["W2S"] = w2s.W2S.schema()
schema["components"]["schemas"]["NestedInW2"] = w2s.NestedInW2.schema()
schema["components"]["schemas"]["AnotherNestedInW2"] = w2s.AnotherNestedInW2.schema()
open_api = construct_open_api_with_schema_class(OpenAPI.parse_obj(schema))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.