From 1c75175e0a5bc85dc02e208258d5d1013f209781 Mon Sep 17 00:00:00 2001 From: Francesco Bartoli Date: Sat, 6 Apr 2024 21:38:41 +0200 Subject: [PATCH] Fix missing not found response for options method Fix missing not found response for options method --- app/pygeoapi/models.py | 11 +++++++++++ app/pygeoapi/openapi.py | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 app/pygeoapi/models.py diff --git a/app/pygeoapi/models.py b/app/pygeoapi/models.py new file mode 100644 index 0000000..ac94628 --- /dev/null +++ b/app/pygeoapi/models.py @@ -0,0 +1,11 @@ +"""pygeoapi models module.""" + +from openapi_pydantic.v3.v3_0_3 import Reference + +not_found = { + "404": Reference( + **{ + "$ref": "https://schemas.opengis.net/ogcapi/features/part1/1.0/openapi/ogcapi-features-1.yaml#/components/responses/NotFound" # noqa + } + ) +} diff --git a/app/pygeoapi/openapi.py b/app/pygeoapi/openapi.py index 93fa005..fdd7cd4 100644 --- a/app/pygeoapi/openapi.py +++ b/app/pygeoapi/openapi.py @@ -9,6 +9,7 @@ from app.auth.models import unauthorized from app.config.app import configuration as cfg from app.config.logging import create_logger +from app.pygeoapi.models import not_found logger = create_logger("app.pygeoapi.openapi") @@ -61,6 +62,8 @@ def augment_security(doc: str, security_schemes: List[SecurityScheme]) -> OpenAP ] if value.options.responses: value.options.responses.update(unauthorized) + # Remove when it is fixed from pygeoapi + value.options.responses.update(not_found) if value.delete: value.delete.security = [ {f"pygeoapi {cfg.PYGEOAPI_SECURITY_SCHEME}": []}