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:
Hej, Andreas & Michael here!
We launched the cloudonaut blog in 2015. Since then, we have published 325 articles: small tips and tricks, best practices, and service reviews. We enjoy writing about all things AWS a lot.
Do you like our blog posts and podcast episodes? Have you learned something new? Consider supporting us create in-depth and independent AWS content. Please help us with a monthly or one-time payment through GitHub Sponsors.Start supporting us today!
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.