Reference API Gateway Models in CloudFormation
API Gateway Models are defined using JSON Schema. You can reference a Model inside another Model using the
$ref field. If you are familiar with the OpenAPI Specification fka Swagger, you may have seen something like this:
To make model references work with API Gateway, you need to provide an absolute reference that is predefined by AWS:
Please support our work!
We have published 327 articles, 41 podcast episodes, and 15 videos. It's all free and means a lot of work in our spare time.
Thanks to Alan Leech, Alex DeBrie, e9e4e5f0faef, Goran Opacic, jhoadley, Shawn Tolidano, Thorsten Hoeger, Todd Valentine, Vince Fulco, and all anonymous supporters for your help! We also want to thank all supporters who purchased a cloudonaut t-shirt. It gives us great pleasure to send our t-shirts all over the world.
With your help, we can continue to produce independent & high-quality content focused on AWS. Please support us!Support us
Let’s translate this to a CloudFormation template:
That’s it. Now you can build sophisticated API Gateway models that reference each other in CloudFormation.