Skip to content

Commit 00b1445

Browse files
authored
Update openapi.py (#1966)
* Update openapi.py * fix indentation * fix flake
1 parent b616fb0 commit 00b1445

File tree

1 file changed

+129
-125
lines changed

1 file changed

+129
-125
lines changed

pygeoapi/openapi.py

Lines changed: 129 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -560,136 +560,140 @@ def get_oas_30(cfg: dict, fail_on_invalid_collection: bool = True) -> dict:
560560
def get_oas_30_parameters(cfg: dict, locale_: str):
561561
server_locales = l10n.get_locales(cfg)
562562

563-
return {
564-
'f': {
565-
'name': 'f',
566-
'in': 'query',
567-
'description': 'The optional f parameter indicates the output format which the server shall provide as part of the response document. The default format is GeoJSON.', # noqa
568-
'required': False,
569-
'schema': {
570-
'type': 'string',
571-
'enum': ['json', 'html', 'jsonld'],
572-
'default': 'json'
573-
},
574-
'style': 'form',
575-
'explode': False
576-
},
577-
'lang': {
578-
'name': 'lang',
579-
'in': 'query',
580-
'description': 'The optional lang parameter instructs the server return a response in a certain language, if supported. If the language is not among the available values, the Accept-Language header language will be used if it is supported. If the header is missing, the default server language is used. Note that providers may only support a single language (or often no language at all), that can be different from the server language. Language strings can be written in a complex (e.g. "fr-CA,fr;q=0.9,en-US;q=0.8,en;q=0.7"), simple (e.g. "de") or locale-like (e.g. "de-CH" or "fr_BE") fashion.', # noqa
581-
'required': False,
582-
'schema': {
583-
'type': 'string',
584-
'enum': [l10n.locale2str(sl) for sl in server_locales],
585-
'default': l10n.locale2str(locale_)
586-
}
587-
},
588-
'skipGeometry': {
589-
'name': 'skipGeometry',
590-
'in': 'query',
591-
'description': 'This option can be used to skip response geometries for each feature.', # noqa
592-
'required': False,
593-
'style': 'form',
594-
'explode': False,
595-
'schema': {
596-
'type': 'boolean',
597-
'default': False
598-
}
599-
},
600-
'crs': {
601-
'name': 'crs',
602-
'in': 'query',
603-
'description': 'Indicates the coordinate reference system for the results.', # noqa
604-
'style': 'form',
605-
'required': False,
606-
'explode': False,
607-
'schema': {
608-
'format': 'uri',
609-
'type': 'string'
610-
}
611-
},
612-
'bbox': {
613-
'name': 'bbox',
614-
'in': 'query',
615-
'description': 'Only features that have a geometry that intersects the bounding box are selected.' # noqa
616-
'The bounding box is provided as four or six numbers, depending on whether the ' # noqa
617-
'coordinate reference system includes a vertical axis (height or depth).', # noqa
618-
'required': False,
619-
'style': 'form',
620-
'explode': False,
621-
'schema': {
622-
'type': 'array',
623-
'minItems': 4,
624-
'maxItems': 6,
625-
'items': {
626-
'type': 'number'
627-
}
628-
}
629-
},
630-
'bbox-crs': {
631-
'name': 'bbox-crs',
632-
'in': 'query',
633-
'description': 'Indicates the coordinate reference system for the given bbox coordinates.', # noqa
634-
'style': 'form',
635-
'required': False,
636-
'explode': False,
637-
'schema': {
638-
'format': 'uri',
639-
'type': 'string'
640-
}
563+
oas_30_parameters = {
564+
'f': {
565+
'name': 'f',
566+
'in': 'query',
567+
'description': 'The optional f parameter indicates the output format which the server shall provide as part of the response document. The default format is GeoJSON.', # noqa
568+
'required': False,
569+
'schema': {
570+
'type': 'string',
571+
'enum': ['json', 'html', 'jsonld'],
572+
'default': 'json'
641573
},
642-
# FIXME: This is not compatible with the bbox-crs definition in
643-
# OGCAPI Features Part 2!
644-
# We need to change the mapscript provider and
645-
# get_collection_map() method in the API!
646-
# So this is for de map-provider only.
647-
'bbox-crs-epsg': {
648-
'name': 'bbox-crs',
649-
'in': 'query',
650-
'description': 'Indicates the EPSG for the given bbox coordinates.', # noqa
651-
'required': False,
652-
'style': 'form',
653-
'explode': False,
654-
'schema': {
655-
'type': 'integer',
656-
'default': 4326
574+
'style': 'form',
575+
'explode': False
576+
},
577+
'lang': {
578+
'name': 'lang',
579+
'in': 'query',
580+
'description': 'The optional lang parameter instructs the server return a response in a certain language, if supported. If the language is not among the available values, the Accept-Language header language will be used if it is supported. If the header is missing, the default server language is used. Note that providers may only support a single language (or often no language at all), that can be different from the server language. Language strings can be written in a complex (e.g. "fr-CA,fr;q=0.9,en-US;q=0.8,en;q=0.7"), simple (e.g. "de") or locale-like (e.g. "de-CH" or "fr_BE") fashion.', # noqa
581+
'required': False,
582+
'schema': {
583+
'type': 'string',
584+
'enum': [l10n.locale2str(sl) for sl in server_locales],
585+
'default': l10n.locale2str(locale_)
586+
}
587+
},
588+
'skipGeometry': {
589+
'name': 'skipGeometry',
590+
'in': 'query',
591+
'description': 'This option can be used to skip response geometries for each feature.', # noqa
592+
'required': False,
593+
'style': 'form',
594+
'explode': False,
595+
'schema': {
596+
'type': 'boolean',
597+
'default': False
598+
}
599+
},
600+
'crs': {
601+
'name': 'crs',
602+
'in': 'query',
603+
'description': 'Indicates the coordinate reference system for the results.', # noqa
604+
'style': 'form',
605+
'required': False,
606+
'explode': False,
607+
'schema': {
608+
'format': 'uri',
609+
'type': 'string'
610+
}
611+
},
612+
'bbox': {
613+
'name': 'bbox',
614+
'in': 'query',
615+
'description': 'Only features that have a geometry that intersects the bounding box are selected.' # noqa
616+
'The bounding box is provided as four or six numbers, depending on whether the ' # noqa
617+
'coordinate reference system includes a vertical axis (height or depth).', # noqa
618+
'required': False,
619+
'style': 'form',
620+
'explode': False,
621+
'schema': {
622+
'type': 'array',
623+
'minItems': 4,
624+
'maxItems': 6,
625+
'items': {
626+
'type': 'number'
657627
}
628+
}
629+
},
630+
'bbox-crs': {
631+
'name': 'bbox-crs',
632+
'in': 'query',
633+
'description': 'Indicates the coordinate reference system for the given bbox coordinates.', # noqa
634+
'style': 'form',
635+
'required': False,
636+
'explode': False,
637+
'schema': {
638+
'format': 'uri',
639+
'type': 'string'
640+
}
641+
},
642+
# FIXME: This is not compatible with the bbox-crs definition in
643+
# OGCAPI Features Part 2!
644+
# We need to change the mapscript provider and
645+
# get_collection_map() method in the API!
646+
# So this is for de map-provider only.
647+
'bbox-crs-epsg': {
648+
'name': 'bbox-crs',
649+
'in': 'query',
650+
'description': 'Indicates the EPSG for the given bbox coordinates.', # noqa
651+
'required': False,
652+
'style': 'form',
653+
'explode': False,
654+
'schema': {
655+
'type': 'integer',
656+
'default': 4326
657+
}
658+
},
659+
'offset': {
660+
'name': 'offset',
661+
'in': 'query',
662+
'description': 'The optional offset parameter indicates the index within the result set from which the server shall begin presenting results in the response document. The first element has an index of 0 (default).', # noqa
663+
'required': False,
664+
'schema': {
665+
'type': 'integer',
666+
'minimum': 0,
667+
'default': 0
658668
},
659-
'offset': {
660-
'name': 'offset',
661-
'in': 'query',
662-
'description': 'The optional offset parameter indicates the index within the result set from which the server shall begin presenting results in the response document. The first element has an index of 0 (default).', # noqa
663-
'required': False,
664-
'schema': {
665-
'type': 'integer',
666-
'minimum': 0,
667-
'default': 0
668-
},
669-
'style': 'form',
670-
'explode': False
671-
},
672-
'vendorSpecificParameters': {
673-
'name': 'vendorSpecificParameters',
674-
'in': 'query',
675-
'description': 'Additional "free-form" parameters that are not explicitly defined', # noqa
676-
'schema': {
677-
'type': 'object',
678-
'additionalProperties': True
679-
},
680-
'style': 'form'
669+
'style': 'form',
670+
'explode': False
671+
},
672+
'vendorSpecificParameters': {
673+
'name': 'vendorSpecificParameters',
674+
'in': 'query',
675+
'description': 'Additional "free-form" parameters that are not explicitly defined', # noqa
676+
'schema': {
677+
'type': 'object',
678+
'additionalProperties': True
681679
},
682-
'resourceId': {
683-
'name': 'resourceId',
684-
'in': 'path',
685-
'description': 'Configuration resource identifier',
686-
'required': True,
687-
'schema': {
688-
'type': 'string',
689-
'default': list(cfg['resources'].keys())[0]
690-
}
691-
}
680+
'style': 'form'
681+
},
682+
'resourceId': {
683+
'name': 'resourceId',
684+
'in': 'path',
685+
'description': 'Configuration resource identifier',
686+
'required': True,
687+
'schema': {
688+
'type': 'string'
689+
}
692690
}
691+
}
692+
if len(list(cfg['resources'].keys())) > 0:
693+
oas_30_parameters['resourceId']['schema']['default'] = list(
694+
cfg['resources'].keys()
695+
)[0]
696+
return oas_30_parameters
693697

694698

695699
def get_visible_collections(cfg: dict) -> dict:

0 commit comments

Comments
 (0)