Coverage for src/configuration/openapi_parsing.py: 0%
8 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-03-20 23:21 -0400
« prev ^ index » next coverage.py v7.6.10, created at 2025-03-20 23:21 -0400
1"""For parsing OpenAPI spec and converting to CueCode config objects"""
3from jsonref import JsonRef # pylint: disable = import-error
5from common.models.openapi_server import OpenAPIServer
8def make_oa_servers_from_json(
9 oa_servers: list[OpenAPIServer], json: JsonRef
10): # pylint: disable=import-error
11 """
12 Build Server objects, only for the top-level "servers" key/object.
13 This is in contrast to documented OpenAPI behavior which allows
14 one to override the server base path per endpoint. Our prototype
15 does not support that behavior.
17 We also depart from the spec in that do not support relative paths
18 for the server url.
20 See https://swagger.io/docs/specification/v3_0/api-host-and-base-path/
21 """
22 json_servers = json["servers"]
23 for s in json_servers:
24 print(s)
25 oas = OpenAPIServer(url=s["url"])
26 oa_servers.append(oas)