Skip to content

Commit 33624fc

Browse files
psychedelicioushipsterusername
authored andcommitted
fix(api): duplicate operation id for get_image_full
There's a FastAPI bug that results in the OpenAPI spec outputting the same operation id for each operation when specifying multiple HTTP methods. - Discussion: fastapi/fastapi#8449 - Pending PR to fix: fastapi/fastapi#10694 In our case, we have a `get_image_full` endpoint that handles GET and HEAD. This results in an invalid OpenAPI schema. A workaround is to use two route decorators for the operation handler. This works as expected - HEAD requests get the header, and GET requests get the resource. And the OpenAPI schema is valid.
1 parent 09d1e19 commit 33624fc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

invokeai/app/api/routers/images.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,8 @@ async def get_image_workflow(
218218
raise HTTPException(status_code=404)
219219

220220

221-
@images_router.api_route(
221+
@images_router.get(
222222
"/i/{image_name}/full",
223-
methods=["GET", "HEAD"],
224223
operation_id="get_image_full",
225224
response_class=Response,
226225
responses={
@@ -231,6 +230,18 @@ async def get_image_workflow(
231230
404: {"description": "Image not found"},
232231
},
233232
)
233+
@images_router.head(
234+
"/i/{image_name}/full",
235+
operation_id="get_image_full_head",
236+
response_class=Response,
237+
responses={
238+
200: {
239+
"description": "Return the full-resolution image",
240+
"content": {"image/png": {}},
241+
},
242+
404: {"description": "Image not found"},
243+
},
244+
)
234245
async def get_image_full(
235246
image_name: str = Path(description="The name of full-resolution image file to get"),
236247
) -> Response:

0 commit comments

Comments
 (0)