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:
Level up, strengthen your AWS skills.
Our book Amazon Web Services in Action is a comprehensive introduction to computing, storing, and networking in the AWS cloud. You'll find clear, relevant coverage of all the essential AWS services, emphasizing best practices for security, high availability, and scalability. Get the first chapter for free!
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.