swaggeropenapigoogle-cloud-endpoints

How do you reuse the same openapi.yaml file for production and development


We are using a GitOps model for deploying our software. Everything in dev branch goes to the dev environment and everything in main gets deployed to production. All good and fine except that we use Google Cloud Endpoints that rely in the host parameter of the openapi.yaml. There is only room for a single value so we have to remember to change it for each deployment not allowing us to do a fully automated deploy.

How do you manage the same openapi.yaml definition when using Google Cloud Endpoints?


Solution

  • There is one example given in the official documentation, see if it helps your use-case.

    1. Basic structure of an OpenAPI document, notice how the "host" is parameterized with "YOUR-PROJECT-ID.appspot.com"
    2. Deploying the Endpoints configuration, using the provided script "./deploy_api.sh"
    3. Source code for deploy_api.sh

    One common solution for different environments properties management is to create different build profiles, and create different environment specific properties files like openapi_dev.yaml, openapi_qa.yaml, openapi_prod.yaml, and supply the one based on the profile(dev/qa/prod) being used. Refer here for more details.

    Another way documented at GitOps-style continuous delivery with Cloud Build, where a multi branch, multi-repository approach is suggested.