Skip to content

Using OpenAPI Spec

You can use the render apiproxy command to create an Apigee API proxy bundle using a template and an OpenAPI spec as input.

How it works

  • Start with Your Template

    This is your baseline. Include any standard policies or settings you want in your final proxy.

  • Customize the Output

    Your template uses special placeholders that are replaced with details from your OpenAPI spec.

  • Control the Output

    Use control logic in your template to adjust your proxy configuration based on your OpenAPI spec.

  • Access the Spec

    Use --set-oas to access the OpenAPI as a map (and as text) during template rendering.

Note

Both OAS2 and OAS3 are supported using the --set-oas flag

Examples

Check out the included OAS3 template at examples/templates/oas3.

Here is how you would use the render apiproxy command with this example:

Create bundle zip

apigee-go-gen render apiproxy \
    --template ./examples/templates/oas3/apiproxy.yaml \
    --set-oas spec=./examples/specs/oas3/petstore.yaml \
    --include ./examples/templates/oas3/*.tmpl \
    --output ./out/apiproxies/petstore.zip

Create bundle dir

apigee-go-gen render apiproxy \
    --template ./examples/templates/oas3/apiproxy.yaml \
    --set-oas spec=./examples/specs/oas3/petstore.yaml \
    --include ./examples/templates/oas3/*.tmpl \
    --output ./out/apiproxies/petstore

Dry run

For rapid development, you can print the rendered template directly to stdout in your terminal.

Add the --dry-run xml or --dry-run yaml flag. e.g.

apigee-go-gen render apiproxy \
    --template ./examples/templates/oas3/apiproxy.yaml \
    --set-oas spec=./examples/specs/oas3/petstore.yaml \
    --include ./examples/templates/oas3/*.tmpl \
    --dry-run xml