@@ -134,6 +134,52 @@ def gen_response_object(description: str, media_type: str,
134134 return response
135135
136136
137+ def gen_contact (cfg : dict ) -> dict :
138+ """
139+ Generates an OpenAPI contact object with OGC extensions
140+ based on OGC API - Records contact
141+
142+ :param cfg: `dict` of configuration
143+
144+ :returns: `dict` of OpenAPI contact object
145+ """
146+
147+ contact = {
148+ 'name' : cfg ['metadata' ]['provider' ]['name' ],
149+ 'url' : cfg ['metadata' ]['provider' ]['url' ],
150+ 'email' : cfg ['metadata' ]['contact' ]['email' ]
151+ }
152+
153+ contact ['x-ogc-serviceContact' ] = {
154+ 'name' : cfg ['metadata' ]['contact' ]['name' ],
155+ 'position' : cfg ['metadata' ]['contact' ]['position' ],
156+ 'addresses' : [{
157+ 'deliveryPoint' : [cfg ['metadata' ]['contact' ]['address' ]],
158+ 'city' : cfg ['metadata' ]['contact' ]['city' ],
159+ 'administrativeArea' : cfg ['metadata' ]['contact' ]['stateorprovince' ], # noqa
160+ 'postalCode' : cfg ['metadata' ]['contact' ]['postalcode' ],
161+ 'country' : cfg ['metadata' ]['contact' ]['country' ]
162+ }],
163+ 'phones' : [{
164+ 'type' : 'main' , 'value' : cfg ['metadata' ]['contact' ]['phone' ]
165+ }, {
166+ 'type' : 'fax' , 'value' : cfg ['metadata' ]['contact' ]['fax' ]
167+ }],
168+ 'emails' : [{
169+ 'value' : cfg ['metadata' ]['contact' ]['email' ]
170+ }],
171+ 'contactInstructions' : cfg ['metadata' ]['contact' ]['instructions' ],
172+ 'links' : [{
173+ 'type' : 'text/html' ,
174+ 'href' : cfg ['metadata' ]['contact' ]['url' ]
175+ }],
176+ 'hoursOfService' : cfg ['metadata' ]['contact' ]['hours' ],
177+ 'roles' : [cfg ['metadata' ]['contact' ]['role' ]]
178+ }
179+
180+ return contact
181+
182+
137183def get_oas_30 (cfg : dict , fail_on_invalid_collection : bool = True ) -> dict :
138184 """
139185 Generates an OpenAPI 3.0 Document
@@ -167,11 +213,7 @@ def get_oas_30(cfg: dict, fail_on_invalid_collection: bool = True) -> dict:
167213 'x-keywords' : l10n .translate (cfg ['metadata' ]['identification' ]['keywords' ], locale_ ), # noqa
168214 'termsOfService' :
169215 cfg ['metadata' ]['identification' ]['terms_of_service' ],
170- 'contact' : {
171- 'name' : cfg ['metadata' ]['provider' ]['name' ],
172- 'url' : cfg ['metadata' ]['provider' ]['url' ],
173- 'email' : cfg ['metadata' ]['contact' ]['email' ]
174- },
216+ 'contact' : gen_contact (cfg ),
175217 'license' : {
176218 'name' : cfg ['metadata' ]['license' ]['name' ],
177219 'url' : cfg ['metadata' ]['license' ]['url' ]
0 commit comments