Adding environment variables to swagger documentation

Viewed 1116

I have swagger.json file and the following AWS-lambda that serves it:

def get_openapi_spec(event, context):
    """
    Returns the VarSAP Open API document.
    """
    swagger_config = os.path.join(os.path.dirname(os.path.relpath(__file__)), "swagger.json")

    with open(swagger_config, "r") as content:
        schema = json.load(content)

    response = {
        "statusCode": 200,
        "headers": {"Content-Type": "application/json"},
        "body": json.dumps(schema),
    }
    return response

This provides the documentation for AWS-lambda based API (written in python).

The information needs to be slightly different, based on the environment (development, integration, user acceptance, production). Environment information is available in environment variables.

For example, the information displayed contains text: Contact email: <email>. Additional information: <url> - where email and url can be found in environment variables.

How do I incorporate the values from environment variables?

0 Answers
Related