We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a Pydantic Field with examples in a request or response model, the generated OpenAPI 3.0.x spec is invalid. See #45 for details.
Field
examples
Here is a test case that can be added to https://github.com/mike-oakley/openapi-pydantic/blob/main/tests/v3_0/test_validated_schema.py:
def test_field_with_examples() -> None: class SampleModel(BaseModel): field: str = Field(default="default", examples=["example1", "example2"]) part_api = construct_sample_api(SampleModel) api = construct_open_api_with_schema_class(part_api) assert api.components is not None assert api.components.schemas is not None if PYDANTIC_V2: json_api: Any = api.model_dump(mode="json", by_alias=True, exclude_none=True) else: json_api: Any = api.dict(by_alias=True, exclude_none=True) validate(json_api)
As a simple fix, we currently replace this line in our fork:
- example: Optional[Any] = None + examples: Optional[Any] = Field(default=None, alias="example")
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When using a Pydantic
Field
withexamples
in a request or response model, the generated OpenAPI 3.0.x spec is invalid. See #45 for details.Here is a test case that can be added to https://github.com/mike-oakley/openapi-pydantic/blob/main/tests/v3_0/test_validated_schema.py:
As a simple fix, we currently replace this line in our fork:
The text was updated successfully, but these errors were encountered: