Skip to content
New issue

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

feat(OpenAPI): lazy import example creator #2390

Merged
merged 1 commit into from
Sep 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion litestar/_openapi/schema_generation/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
create_numerical_constrained_field_schema,
create_string_constrained_field_schema,
)
from litestar._openapi.schema_generation.examples import create_examples_for_field
from litestar._openapi.schema_generation.utils import sort_schemas_and_references
from litestar.datastructures import UploadFile
from litestar.exceptions import ImproperlyConfiguredException
Expand Down Expand Up @@ -586,6 +585,8 @@ def process_schema_result(self, field: FieldDefinition, schema: Schema) -> Schem
setattr(schema, schema_key, value)

if not schema.examples and self.generate_examples:
from litestar._openapi.schema_generation.examples import create_examples_for_field

schema.examples = create_examples_for_field(field)

if schema.title and schema.type in (OpenAPIType.OBJECT, OpenAPIType.ARRAY):
Expand Down