pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
80 stars 23 forks source link

Support list responses #16

Open pgjones opened 2 years ago

pgjones commented 2 years ago

How to indicate and type hint this?

@validate_response(list[Model]) ??

maxyz commented 1 year ago

You can have something like:

@dataclass
class Models:
    __root__: list[Model]

That way the schema is shown fine, but you'll need to change the way the reply is handled. (PydanticModel.asdict will be a dict including root, while PydanticModel.json produces a nicer the list result)