According to the documentation:
If neither DefinitionUri nor DefinitionBody are specified, SAM will generate a DefinitionBody for you based on your template configuration.
However, I can't seem to find any materials describing how this process takes place. This leaves me with two questions:
- Is this done by the SAM CLI or is it performed somewhere in AWS's backend?
- Can this automatic generation be configured, or is manually specifying a definition the only way to customize how the API behaves?
I like that it can automatically configure this for us, but the default behavior needs slight tweaking to fit my use case.
-
do you mean auto generation or customizion?Ashish Kamble– Ashish Kamble2025年08月01日 08:39:51 +00:00Commented Aug 1, 2025 at 8:39
-
@AshishKamble Customization of the auto-generation, preferably.Brandon Lee– Brandon Lee2025年08月01日 14:07:08 +00:00Commented Aug 1, 2025 at 14:07
1 Answer 1
I don't know all the details, but SAM basically generates the definition body depending on the configuration of your Apis and Functions present in your SAM template.
SAM is open source, so you can see the code. This class probably handles the low-level changes that need to be made: https://github.com/aws/serverless-application-model/blob/develop/samtranslator/swagger/swagger.py#L22 , and it's used in different places depending on the configuration on your SAM template, for example, if you have a Lambda function integration for your API.
This is not done by SAM CLI, but it's done by SAM, the transform that runs in CloudFormation. When you add the AWS::Serverless-2016年10月31日 Transform, then your SAM template and resources get transformed server side into the equivalent CloudFormation (AWS::ApiGateway:: or AWS::ApiGatewayv2::) resources
Comments
Explore related questions
See similar questions with these tags.