Skip to content

Commit

Permalink
implement openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Nov 17, 2023
1 parent c0da251 commit 5651766
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion metadata_catalogue/datasets/geoapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.apps import apps
from django.db import models
from pygeoapi.openapi import get_oas
from solo.models import SingletonModel

from ..libs.utils import safe_get
Expand All @@ -24,7 +25,7 @@ def get_config(self, url=""):
id: value for id, value in Dataset.objects.select_related("metadata").all().as_geoapi_resource(url)
}

return {
conf = {
"server": {
"mimetype": "application/xml; charset=UTF-8",
"encoding": "utf-8",
Expand Down Expand Up @@ -77,3 +78,6 @@ def get_config(self, url=""):
},
"resources": resources,
}

openapi = get_oas(conf)
return conf, openapi
4 changes: 2 additions & 2 deletions metadata_catalogue/datasets/geoapi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ def _feed_response(request: HttpRequest, api_definition: str, *args, **kwargs) -
"""Use pygeoapi api to process the input request"""

config = GeoAPIConfig.get_solo()
as_dict = config.get_config(req_to_base(request))
api_ = API(as_dict, {})
geoapi_conf, openapi_def = config.get_config(req_to_base(request))
api_ = API(geoapi_conf, openapi_def)
api = getattr(api_, api_definition)
return api(request, *args, **kwargs)

Expand Down

0 comments on commit 5651766

Please sign in to comment.