Adding response documentation to Serverless API and Lambda Function SAM/Cloudformation template

0

What I'm trying to do:

I'm trying to create an API using API Gateway that invokes a Lambda Function. I am trying these objects in AWS using SAM templates and deploying to Cloudformation. I am also trying to make sure that generated documentation (Swagger/OpenApi) appears correctly (specifically for response status code, body, and description). Additionally, my goal is to keep the project simple for myself and my fellow team members who do not work with this technology regularly.

How I've done it so far:

I've used AWS::Serverless::Api and AWS::Serverless::Function within my templates since they provide more features without having to define individual methods within API Gateway. With these tools, I've been able to create the functionality of what I'm trying to achieve along with some (but not all) of the documentation I would like to see.

The issue:

Within the documentation of both AWS::Serverless::Api and AWS::Serverless::Function, I see no reference to Method Responses. As a result, the documentation that is generated does not contain response(s). Not entirely surprising because I'm not defining them in the template, but I have been unsuccessful in finding where they might be defined.

What I've tried so far:

I've tried using Documentation Parts, defining the method explicitly, and briefly attempted to use a separate yaml file for the definition body (which I don't want to do). None of these have fixed the issue.

Question:

Is there a way to define a response/method response while using only AWS::Serverless::Api and AWS::Serverless::Function within the template without the use of DefinitionBody or a separate yaml file?

Thank you!

Thank you for reading this! I am open to trying new solutions and I'll be happy to share the testing template I've been working with if that helps answer the question.

1 個回答
1

Hi,

As far as I know, no. You can provide body definition in separated openapi yaml (https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-api.html), but as you said it is not what you are after.

Hope it clarifies thought.

profile picture
專家
已回答 1 年前
  • Hi! Thanks for responding! Yeah I saw that as a solution, and I think I might have to go down that route inevitably, but I'm trying to keep everything in the same file if possible.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南