Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Validation Error Model with internal field as pydantic<BaseModel> #118

Unanswered
SeFeX asked this question in Q&A
Discussion options

Hello
I'm changing the validation_error_model and this has a internal field with other model:

def create_openapi():
 return OpenAPI(__name__,
 info=info,
 servers=servers,
 doc_ui=doc_ui_enabled,
 validation_error_status=400,
 validation_error_model=GenericError,
 validation_error_callback=validation_error_handler)

This is the generic error model:

class GenericError(BaseModel):
 errorCode: str = Field(..., example="400")
 message: str = Field(..., example="Bad Request")
 help: str = Field(..., example="Bad Request")
 location: str = Field(..., example="/path/error")
 moreInfo: list[GenericTracebackError] = Field(..., example=[GenericTracebackError(
 location="GenericError.py",
 line=1,
 method="GenericError",
 message="400:Bad Request")])

And this is the model of traceback error:

class GenericTracebackError(BaseModel):
 location: str = Field(..., example="GenericError.py")
 line: int = Field(..., example=1)
 method: str = Field(..., example="GenericError")
 message: str = Field(..., example="400:Bad Request")

But the problem is that in the openapi.json file, only the GenericError model is added, the GenericTracebackError model is not automatically added:
image
And show this error:

Errors
Resolver error at components.schemas.GenericError.properties.moreInfo.items.$ref
Could not resolve reference: Could not resolve pointer: /definitions/GenericTracebackError does not exist in document

How can I manually add this model to the openapi.json schemes or how can I add it to the definitions so that the internal model is found?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

I can confirm this is a bug and I will fix it.

You must be logged in to vote
1 reply
Comment options

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /