BlackSheep
BlackSheep copied to clipboard
Add support for Union types in OpenAPI Doc generation
🚀 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))