tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.66k stars 387 forks source link

"validation errors for OpenAPI" when requesting /docs #1415

Open feakuru opened 1 year ago

feakuru commented 1 year ago

Describe the bug I followed the example in https://tortoise.github.io/examples/fastapi.html#basic-non-relational-example, and when running the app and requesting '/docs', I get a "Fetch error: Internal Server Error /openapi.json"

To Reproduce https://tortoise.github.io/examples/fastapi.html#basic-non-relational-example

Expected behavior No errors.

Additional context Traceback:

Traceback (most recent call last):
  ...
    return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True)  # type: ignore
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 2 validation errors for OpenAPI
components -> schemas -> models.user.User.leaf -> additionalProperties
  value is not a valid dict (type=type_error.dict)
components -> schemas -> models.user.User.leaf -> $ref
  field required (type=value_error.missing)
feakuru commented 1 year ago

update: seems like this is caused by changes in fastapi 0.99.0. changing the version to 0.98.0 resolves the issue. maybe it has to do with the fact that they added support for OpenAPI 3.1.0 in fastapi 0.99.0?..