File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
aws_lambda_powertools/event_handler/openapi Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -119,14 +119,14 @@ def __get_pydantic_core_schema__(
119
119
cls ._validate ,
120
120
serialization = core_schema .to_string_ser_schema (),
121
121
)
122
-
122
+
123
123
# Add OpenAPI schema info
124
124
schema ["json_schema_extra" ] = {
125
125
"type" : "string" ,
126
126
"format" : "binary" ,
127
127
"description" : "A file uploaded as part of a multipart/form-data request" ,
128
128
}
129
-
129
+
130
130
return schema
131
131
132
132
@classmethod
@@ -137,27 +137,25 @@ def _validate(cls, value: Any) -> UploadFile:
137
137
if isinstance (value , bytes ):
138
138
return cls (file = value )
139
139
raise ValueError (f"Expected UploadFile or bytes, got { type (value )} " )
140
-
140
+
141
141
@classmethod
142
142
def __get_validators__ (cls ):
143
143
"""Return validators for Pydantic v1 compatibility."""
144
144
yield cls ._validate
145
-
145
+
146
146
@classmethod
147
- def __get_pydantic_json_schema__ (
148
- cls , _core_schema : Any , field_schema : Any
149
- ) -> dict [str , Any ]:
147
+ def __get_pydantic_json_schema__ (cls , _core_schema : Any , field_schema : Any ) -> dict [str , Any ]:
150
148
"""Modify the JSON schema for OpenAPI compatibility."""
151
149
# Handle both Pydantic v1 and v2 schemas
152
150
json_schema = field_schema (_core_schema ) if callable (field_schema ) else {}
153
-
151
+
154
152
# Add binary file format for OpenAPI
155
153
json_schema .update (
156
154
type = "string" ,
157
155
format = "binary" ,
158
156
description = "A file uploaded as part of a multipart/form-data request" ,
159
157
)
160
-
158
+
161
159
return json_schema
162
160
163
161
You can’t perform that action at this time.
0 commit comments