You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#from pydantic.dataclasses import dataclassfrompydantic.dataclassesimportdataclass@dataclassclassRegisterBody:
name: stremail: strpassword: str@validator('name')defvalidate_name(cls, v):
iflen(v) <5:
raiseValueError('name must be at leasth 5 characters')
@app.post("/register")@openapi.body({"application/json": RegisterBody})@validate(json=RegisterBody)asyncdefregister(request, body):
returnjson({})
The code above produces the OpenAPI /docs page to populate a validator_name field in the Swagger UI, while for the actual mode it is not a field. Tried with the builting python dataclasses and the Pydantic wrapper too.
Sanic v22.3.2
Sanic-ext v22.3.2
Arch Linux x86_64
Python 3.10.4
The text was updated successfully, but these errors were encountered:
Because "schema" is just schema. It's better to have schemas separately from objects with working business logic. You can inherit classes with business logic from schema objects.
The code above produces the OpenAPI
/docs
page to populate avalidator_name
field in the Swagger UI, while for the actual mode it is not a field. Tried with the builting python dataclasses and the Pydantic wrapper too.Sanic v22.3.2
Sanic-ext v22.3.2
Arch Linux x86_64
Python 3.10.4
The text was updated successfully, but these errors were encountered: