Skip to content

Commit 4a5ac3e

Browse files
author
doublebyte1
committed
- added example to update admin config, on Open API
1 parent 2e4ff71 commit 4a5ac3e

File tree

2 files changed

+112
-4
lines changed

2 files changed

+112
-4
lines changed

pygeoapi/openapi.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def get_oas_30(cfg: dict, fail_on_invalid_collection: bool = True) -> dict:
509509
schema_dict = get_config_schema()
510510
oas['definitions'] = schema_dict['definitions']
511511
LOGGER.debug('Adding admin endpoints')
512-
oas['paths'].update(get_admin())
512+
oas['paths'].update(get_admin(cfg))
513513

514514
return oas
515515

@@ -665,8 +665,12 @@ def get_config_schema():
665665
with open(schema_file) as fh2:
666666
return yaml_load(fh2)
667667

668+
def get_admin(cfg: dict) -> dict:
669+
"""
670+
Generates an OpenAPI definition for the admin UI
668671
669-
def get_admin():
672+
:param cfg: `dict` of configuration
673+
"""
670674

671675
schema_dict = get_config_schema()
672676

@@ -702,6 +706,7 @@ def get_admin():
702706
'description': 'Updates admin configuration',
703707
'content': {
704708
'application/json': {
709+
'example': schema_dict['properties']['server']['properties']['admin-post-example'],
705710
'schema': schema_dict
706711
}
707712
},
@@ -810,7 +815,7 @@ def get_admin():
810815
'description': 'Updates admin configuration resource',
811816
'content': {
812817
'application/json': {
813-
'schema': schema_dict['properties']['resources']['patternProperties']['^.*$'] # noqa
818+
'schema': schema_dict['properties']['resources']['patternProperties']['^.*$'], # noqa
814819
}
815820
},
816821
'required': True

pygeoapi/schemas/config/pygeoapi-config-0.x.yml

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,111 @@ properties:
2727
description: URL of server (as used by client)
2828
admin:
2929
type: boolean
30-
description: whether to enable the Admin API (default is false)
3130
default: false
31+
admin-post-example:
32+
server:
33+
bind:
34+
host: 0.0.0.0
35+
port: 5000
36+
url: http://localhost:5000
37+
mimetype: application/json; charset=UTF-8
38+
encoding: utf-8
39+
gzip: false
40+
languages:
41+
- en-US
42+
- fr-CA
43+
# cors: true
44+
pretty_print: true
45+
limit: 10
46+
map:
47+
url: https://tile.openstreetmap.org/{z}/{x}/{y}.png
48+
attribution: '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
49+
admin: true
50+
logging:
51+
level: ERROR
52+
53+
metadata:
54+
identification:
55+
title:
56+
en: New pygeoapi Title
57+
fr: instance par défaut de pygeoapi
58+
description:
59+
en: pygeoapi provides an API to geospatial data
60+
fr: pygeoapi fournit une API aux données géospatiales
61+
keywords:
62+
en:
63+
- geospatial
64+
- data
65+
- api
66+
fr:
67+
- géospatiale
68+
- données
69+
- api
70+
keywords_type: theme
71+
terms_of_service: https://creativecommons.org/licenses/by/4.0/
72+
url: https://example.org
73+
license:
74+
name: CC-BY 4.0 license
75+
url: https://creativecommons.org/licenses/by/4.0/
76+
provider:
77+
name: Organization Name
78+
url: https://pygeoapi.io
79+
contact:
80+
name: Lastname, Firstname
81+
position: Position Title
82+
address: Mailing Address
83+
city: City
84+
stateorprovince: Administrative Area
85+
postalcode: Zip or Postal Code
86+
country: Country
87+
phone: +xx-xxx-xxx-xxxx
88+
fax: +xx-xxx-xxx-xxxx
89+
email: you@example.org
90+
url: Contact URL
91+
hours: Mo-Fr 08:00-17:00
92+
instructions: During hours of service. Off on weekends.
93+
role: pointOfContact
94+
95+
resources:
96+
obs:
97+
type: collection
98+
title: Observations
99+
description: My cool observations
100+
keywords:
101+
- observations
102+
- monitoring
103+
linked-data:
104+
context:
105+
- datetime: https://schema.org/DateTime
106+
- vocab: https://example.com/vocab#
107+
stn_id: "vocab:stn_id"
108+
value: "vocab:value"
109+
links:
110+
- type: text/csv
111+
rel: canonical
112+
title: data
113+
href: https://github.com/mapserver/mapserver/blob/branch-7-0/msautotest/wxs/data/obs.csv
114+
hreflang: en-US
115+
- type: text/csv
116+
rel: alternate
117+
title: data
118+
href: https://raw.githubusercontent.com/mapserver/mapserver/branch-7-0/msautotest/wxs/data/obs.csv
119+
hreflang: en-US
120+
extents:
121+
spatial:
122+
bbox: [-180,-90,180,90]
123+
crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
124+
temporal:
125+
begin: 2000-10-30T18:24:39Z
126+
end: 2007-10-30T08:57:29Z
127+
providers:
128+
- type: feature
129+
name: CSV
130+
data: tests/data/obs.csv
131+
id_field: id
132+
geometry:
133+
x_field: long
134+
y_field: lat
32135
mimetype:
33136
type: string
34137
description: default MIME type

0 commit comments

Comments
 (0)