Using OpenAPI Description
You can use the render apiproxy command to create an Apigee API proxy bundle using a template and an OpenAPI Description 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 Description.
- Control the Output
Use control logic in your template to adjust your proxy configuration based on your OpenAPI Description.
- Access the OAS Description
Use
--set-oas
to access the OpenAPI Description 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 / Debug
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.
Note that dry-run is only useful when the rendered template produces valid YAML.
If your template has issues, and it does not produce valid YAML, you can use the --debug true
flag.
This will print out the rendered template before even attempting to parse it as YAML.