0

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:

  1. Is this done by the SAM CLI or is it performed somewhere in AWS's backend?
  2. 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.

asked Jul 31, 2025 at 19:29
2
  • do you mean auto generation or customizion? Commented Aug 1, 2025 at 8:39
  • @AshishKamble Customization of the auto-generation, preferably. Commented Aug 1, 2025 at 14:07

1 Answer 1

0

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

answered Nov 4, 2025 at 6:24
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.