tortoise / tortoise/tortoise-orm

"validation errors for OpenAPI" when requesting /docs

Open
#1,415 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the FastAPI basic non-relational example linked in the issue and request /docs, then inspect the generated /openapi.json around the models.user.User.leaf schema. Done means the example serves its OpenAPI document without the reported Pydantic validation errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, openapi, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.