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

Add support for Union types in OpenAPI Doc generation #389

Open
RobertoPrevato opened this issue Jul 2, 2023 · 1 comment
Open

Add support for Union types in OpenAPI Doc generation #389

RobertoPrevato opened this issue Jul 2, 2023 · 1 comment
Assignees
Labels
document Something worth documenting

Comments

@RobertoPrevato
Copy link
Member

🚀 Feature Request

Add support for the following scenarios:

@dataclass
class A:
    a_prop: int


@dataclass
class B:
    b_prop: str


@dataclass
class C:
    c_prop: str


@dataclass
class AnyOfTestClass:
    sub_prop: Union[A, B, C]


@pytest.mark.asyncio
async def test_any_of_dataclasses(docs: OpenAPIHandler, serializer: Serializer):
    app = get_app()
    docs.bind_app(app)

    @app.route("/one")
    def one(data: AnyOfTestClass):
        ...

    await app.start()

    yaml = serializer.to_yaml(docs.generate_documentation(app))
@RobertoPrevato RobertoPrevato self-assigned this Jul 2, 2023
@RobertoPrevato
Copy link
Member Author

  • the same for Pydantic

RobertoPrevato added a commit that referenced this issue Jul 2, 2023
@RobertoPrevato RobertoPrevato added the document Something worth documenting label Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document Something worth documenting
Projects
None yet
Development

No branches or pull requests

1 participant