Skip to content

Commit 6457794

Browse files
fix: resolve FastAPI deprecation warning for example fields (#507)
## PR Summary This small PR resolves deprecation warnings for the `example` parameter in FastAPI's `Form` object, replacing it with the recommended `examples` parameter. These warnings are visible in the [CI logs](https://github.com/Unstructured-IO/unstructured-api/actions/runs/15281651418/job/42982178029#step:4:1697): ```python /home/runner/work/unstructured-api/unstructured-api/prepline_general/api/models/form_params.py:54: DeprecationWarning: `example` has been deprecated, please use `examples` instead ``` Signed-off-by: Emmanuel Ferdman <[email protected]>
1 parent df1edce commit 6457794

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

prepline_general/api/models/form_params.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def as_form(
5454
Form(
5555
title="OCR Languages",
5656
description="The languages present in the document, for use in partitioning and/or OCR",
57-
example="[eng]",
57+
examples=["[eng]"],
5858
),
5959
BeforeValidator(SmartValueParser[List[str]]().value_or_first_element),
6060
] = [], # noqa
@@ -63,7 +63,7 @@ def as_form(
6363
Form(
6464
title="OCR Languages",
6565
description="The languages present in the document, for use in partitioning and/or OCR",
66-
example="[eng]",
66+
examples=["[eng]"],
6767
),
6868
BeforeValidator(SmartValueParser[List[str]]().value_or_first_element),
6969
] = [],
@@ -74,7 +74,7 @@ def as_form(
7474
description=(
7575
"The document types that you want to skip table extraction with. Default: []"
7676
),
77-
example="['pdf', 'jpg', 'png']",
77+
examples=["['pdf', 'jpg', 'png']"],
7878
),
7979
BeforeValidator(SmartValueParser[List[str]]().value_or_first_element),
8080
] = [], # noqa
@@ -83,15 +83,15 @@ def as_form(
8383
Form(
8484
title="Uncompressed Content Type",
8585
description="If file is gzipped, use this content type after unzipping",
86-
example="application/pdf",
86+
examples=["application/pdf"],
8787
),
8888
] = None,
8989
output_format: Annotated[
9090
Literal["application/json", "text/csv"],
9191
Form(
9292
title="Output Format",
9393
description="The format of the response. Supported formats are application/json and text/csv. Default: application/json.",
94-
example="application/json",
94+
examples=["application/json"],
9595
),
9696
] = "application/json",
9797
coordinates: Annotated[
@@ -107,7 +107,7 @@ def as_form(
107107
Form(
108108
title="Content type",
109109
description="A hint about the content type to use (such as text/markdown), when there are problems processing a specific file. This value is a MIME type in the format type/subtype.",
110-
example="text/markdown",
110+
examples=["text/markdown"],
111111
),
112112
BeforeValidator(SmartValueParser[str]().value_or_first_element),
113113
] = None,
@@ -116,7 +116,7 @@ def as_form(
116116
Form(
117117
title="Encoding",
118118
description="The encoding method used to decode the text input. Default: utf-8",
119-
example="utf-8",
119+
examples=["utf-8"],
120120
),
121121
BeforeValidator(SmartValueParser[str]().value_or_first_element),
122122
] = "utf-8",
@@ -125,7 +125,7 @@ def as_form(
125125
Form(
126126
title="Hi Res Model Name",
127127
description="The name of the inference model used when strategy is hi_res",
128-
example="yolox",
128+
examples=["yolox"],
129129
),
130130
BeforeValidator(SmartValueParser[str]().value_or_first_element),
131131
] = None,
@@ -163,7 +163,7 @@ def as_form(
163163
Form(
164164
title="Image block types to extract",
165165
description="The types of elements to extract, for use in extracting image blocks as base64 encoded data stored in metadata fields",
166-
example="""["image", "table"]""",
166+
examples=["""["image", "table"]"""],
167167
),
168168
BeforeValidator(SmartValueParser[List[str]]().value_or_first_element),
169169
] = [], # noqa
@@ -173,7 +173,7 @@ def as_form(
173173
title="unique_element_ids",
174174
description="""When `True`, assign UUIDs to element IDs, which guarantees their uniqueness
175175
(useful when using them as primary keys in database). Otherwise a SHA-256 of element text is used. Default: False""",
176-
example=True,
176+
examples=[True],
177177
),
178178
] = False,
179179
# -- chunking options --
@@ -190,15 +190,15 @@ def as_form(
190190
Form(
191191
title="Combine Under N Chars",
192192
description="If chunking strategy is set, combine elements until a section reaches a length of n chars. Default: 500",
193-
example=500,
193+
examples=[500],
194194
),
195195
] = None,
196196
max_characters: Annotated[
197197
int,
198198
Form(
199199
title="Max Characters",
200200
description="If chunking strategy is set, cut off new sections after reaching a length of n chars (hard max). Default: 1500",
201-
example=1500,
201+
examples=[1500],
202202
),
203203
] = 500,
204204
multipage_sections: Annotated[
@@ -213,7 +213,7 @@ def as_form(
213213
Form(
214214
title="New after n chars",
215215
description="If chunking strategy is set, cut off new sections after reaching a length of n chars (soft max). Default: 1500",
216-
example=1500,
216+
examples=[1500],
217217
),
218218
] = None,
219219
overlap: Annotated[
@@ -223,7 +223,7 @@ def as_form(
223223
description="""Specifies the length of a string ("tail") to be drawn from each chunk and prefixed to the
224224
next chunk as a context-preserving mechanism. By default, this only applies to split-chunks
225225
where an oversized element is divided into multiple chunks by text-splitting. Default: 0""",
226-
example=20,
226+
examples=[20],
227227
),
228228
] = 0,
229229
overlap_all: Annotated[
@@ -233,7 +233,7 @@ def as_form(
233233
description="""When `True`, apply overlap between "normal" chunks formed from whole
234234
elements and not subject to text-splitting. Use this with caution as it entails a certain
235235
level of "pollution" of otherwise clean semantic chunk boundaries. Default: False""",
236-
example=True,
236+
examples=[True],
237237
),
238238
] = False,
239239
starting_page_number: Annotated[
@@ -244,7 +244,7 @@ def as_form(
244244
"When PDF is split into pages before sending it into the API, providing "
245245
"this information will allow the page number to be assigned correctly."
246246
),
247-
example=3,
247+
examples=[3],
248248
),
249249
] = None,
250250
include_slide_notes: Annotated[
@@ -255,7 +255,7 @@ def as_form(
255255
"When `True`, slide notes from .ppt and .pptx files"
256256
" will be included in the response. Default: `True`"
257257
),
258-
example=False,
258+
examples=[False],
259259
),
260260
] = True,
261261
) -> "GeneralFormParams":

0 commit comments

Comments
 (0)