Skip to content

Commit 561b9d8

Browse files
feat: roll openapi json into fastapi (#359)
* Bump Pydantic to 2.5.x and remove it from explicit dependencies list (will be managed by fastapi) * Introduce Form params description in the code, which will form openapi and swagger documentation * Roll back some openapi customizations * Keep backward compatibility for passing parameters in form of `list[str]` (will not be shown in the documentation)
1 parent 63eb9ae commit 561b9d8

File tree

15 files changed

+658
-422
lines changed

15 files changed

+658
-422
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.0.64
2+
* Bump Pydantic to 2.5.x and remove it from explicit dependencies list (will be managed by fastapi)
3+
* Introduce Form params description in the code, which will form openapi and swagger documentation
4+
* Roll back some openapi customizations
5+
* Keep backward compatibility for passing parameters in form of `list[str]` (will not be shown in the documentation)
6+
17
## 0.0.63
28

39
* Bump unstructured to 0.12.2

openapi.json

Lines changed: 0 additions & 280 deletions
This file was deleted.

prepline_general/api/app.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
from fastapi import FastAPI, Request, status, HTTPException
22
from fastapi.responses import JSONResponse
3+
from fastapi.security import APIKeyHeader
34
import logging
45
import os
56

67
from .general import router as general_router
8+
from .openapi import set_custom_openapi
79

810
logger = logging.getLogger("unstructured_api")
911

10-
1112
app = FastAPI(
1213
title="Unstructured Pipeline API",
13-
description="""""",
14-
version="0.0.63",
14+
summary="Partition documents with the Unstructured library",
15+
version="0.0.64",
1516
docs_url="/general/docs",
1617
openapi_url="/general/openapi.json",
18+
servers=[
19+
{
20+
"url": "https://api.unstructured.io",
21+
"description": "Hosted API",
22+
"x-speakeasy-server-id": "prod",
23+
},
24+
{
25+
"url": "http://localhost:8000",
26+
"description": "Development server",
27+
"x-speakeasy-server-id": "local",
28+
},
29+
],
30+
openapi_tags=[{"name": "general"}],
1731
)
1832

1933
# Note(austin) - This logger just dumps exceptions
@@ -49,6 +63,8 @@ async def error_handler(request: Request, e: Exception):
4963

5064
app.include_router(general_router)
5165

66+
set_custom_openapi(app)
67+
5268

5369
# Filter out /healthcheck noise
5470
class HealthCheckFilter(logging.Filter):

0 commit comments

Comments
 (0)