Skip to content

Commit

Permalink
feat(OpenAPI): lazy import example creator (#2390)
Browse files Browse the repository at this point in the history
Signed-off-by: Janek Nouvertné <[email protected]>
  • Loading branch information
provinzkraut authored Sep 30, 2023
1 parent cf22892 commit 2756f7e
Showing 1 changed file with 2 additions and 1 deletion.
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

0 comments on commit 2756f7e

Please sign in to comment.