Giter Site home page Giter Site logo

litestar-org / pydantic-openapi-schema Goto Github PK

View Code? Open in Web Editor NEW
11.0 7.0 4.0 1 MB

Generate OpenAPI 3.x.x using Pydantic

Home Page: https://starlite-api.github.io/pydantic-openapi-schema/

License: MIT License

Python 99.79% Dockerfile 0.21%
openapi pydantic starlite schema starlite-api

pydantic-openapi-schema's People

Contributors

cofin avatar dbanty avatar dependabot[bot] avatar gamazic avatar goldziher avatar jacobcoffee avatar jtraub avatar jtv8 avatar kuimono avatar lgtm-com[bot] avatar oliverhofkens avatar peterschutt avatar phalelashvili avatar provinzkraut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pydantic-openapi-schema's Issues

Parameter doesn't depend on `param_in` attribute

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?

Add an example of how to use

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))

Allow to enable alias for OpenAPI310PydanticSchema

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)

Dependency: python 3.11 will require min pydantic 1.10 or a workaround

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

Update usage of tags

the tags key under Schema is currently typed as Optional[List[str]], but it should actually be Optional[List[Tag]]

Refactor: Remove 3.0.3

Starlite assumes a minimum of 3.1.0, so keeping 3.0.3 models isn't really worth the maintenance burden.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.