Skip to content

Commit dffc2d5

Browse files
authored
Merge pull request #70 from ecmwf-projects/COPDS-2395-improve-swagger-doc
Enable configurable API metadata
2 parents 25a40ae + 734bc2b commit dffc2d5

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

ogc_api_processes_fastapi/main.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""API routes registration and initialization."""
22

33
import typing
4-
from typing import Callable
4+
from typing import Any, Callable
55

66
import fastapi
77
import pydantic
@@ -60,8 +60,26 @@ def instantiate_app(
6060
exception_handler: Callable[
6161
[fastapi.Request, exceptions.OGCAPIException], fastapi.responses.JSONResponse
6262
] = exceptions.ogc_api_exception_handler,
63+
**kwargs: Any,
6364
) -> fastapi.FastAPI:
64-
app = fastapi.FastAPI()
65+
"""Instantiate FastAPI application.
66+
67+
Parameters
68+
----------
69+
client : clients.BaseClient
70+
Client to be used for API requests.
71+
exception_handler : Callable[[fastapi.Request, exceptions.OGCAPIException],
72+
fastapi.responses.JSONResponse], optional
73+
Exception handler, by default exceptions.ogc_api_exception_handler
74+
**kwargs : Any
75+
Additional parameters passed to `fastapi.Fastapi()`.
76+
77+
Returns
78+
-------
79+
fastapi.FastAPI
80+
FastAPI application.
81+
"""
82+
app = fastapi.FastAPI(**kwargs)
6583
router = instantiate_router(client)
6684
app.include_router(router)
6785
app = exceptions.include_exception_handlers(app, exception_handler)

ogc_api_processes_fastapi/models.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ class AdditionalParameter(pydantic.BaseModel):
3434

3535

3636
class JobControlOptions(enum.Enum):
37-
sync_execute: str = "sync-execute"
38-
async_execute: str = "async-execute"
39-
dismiss: str = "dismiss"
37+
sync_execute = "sync-execute"
38+
async_execute = "async-execute"
39+
dismiss = "dismiss"
4040

4141

4242
class TransmissionMode(enum.Enum):
43-
value: str = "value"
44-
reference: str = "reference"
43+
value = "value"
44+
reference = "reference"
4545

4646

4747
class PaginationQueryParameters(pydantic.BaseModel):
@@ -260,11 +260,11 @@ class ProcessDescription(ProcessSummary):
260260

261261

262262
class StatusCode(str, enum.Enum):
263-
accepted: str = "accepted"
264-
running: str = "running"
265-
successful: str = "successful"
266-
failed: str = "failed"
267-
dismissed: str = "dismissed"
263+
accepted = "accepted"
264+
running = "running"
265+
successful = "successful"
266+
failed = "failed"
267+
dismissed = "dismissed"
268268

269269

270270
class JobType(enum.Enum):

0 commit comments

Comments
 (0)