Closed dperjar closed 7 years ago
Can you try upgrading to version 0.5.4? It could be that this bug has to do with the method responses. This could narrow down the problem that you are having.
0.5.4
Seems fine and produces correct output as well.
There is one other thing I noticed... and this may just be a different issue because it happens across all versions, but I have an endpoint using the lambda integration rather than the default proxy integration and it has response codes in the output (more than the ones I've defined, in fact) but has no models assigned to those responses.
The .yml for that endpoint looks like
protectedResource:
handler: handler.protectedResource
events:
- http:
path: protectedresource
method: get
integration: lambda
authorizer:
name: cognitoAuthDemo
arn: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
claims:
- email
documentation:
summary: ""
description: ""
requestBody:
description: ""
requestHeaders:
requestModels:
"application/json": "protectedresourcerequest"
methodResponses:
-
statusCode: 200
responseModels:
"application/json": "protectedresourceresponse"
-
statusCode: 400
responseModels:
"application/json": "errorresponse"
-
statusCode: 502
responseModels:
"application/json": "errorresponse"
And the Swagger export looks like...
/protectedresource:
get:
consumes:
- "application/json"
- "application/x-www-form-urlencoded"
responses:
200:
description: "200 response"
422:
description: "422 response"
400:
description: "400 response"
500:
description: "500 response"
401:
description: "401 response"
502:
description: "502 response"
403:
description: "403 response"
404:
description: "404 response"
504:
description: "504 response"
security:
- 1_CTG7R8Npn: []
I'm guessing this plugin isn't responsible for creating those extra responses, but I haven't tried deploying with the plugin uninstalled. I'm having to use the lambda integration for that endpoint because the newly added Serverless support for Cognito authorizer doesn't support the proxy integration. I'd be interested in knowing if this is a bug, not supported, or perhaps to be supported in a future release.
Thanks for your help.
Ah ... I'm glad I swung by.
I have a regression in v0.5.6 that looks like this.
Here's what cloudformation-template-update-stack.json
looks like for v0.5.5:
"ApiGatewayMethodUsersPost": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"HttpMethod": "POST",
"RequestParameters": {},
"ResourceId": {
"Ref": "ApiGatewayResourceUsers"
},
"RestApiId": {
"Ref": "ApiGatewayRestApi"
},
"AuthorizationType": "NONE",
"Integration": {
"IntegrationHttpMethod": "POST",
"Type": "AWS_PROXY",
"Uri": {
"Fn::Join": [
"",
[
"arn:aws:apigateway:",
{
"Ref": "AWS::Region"
},
":lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"ClientApiLambdaFunction",
"Arn"
]
},
"/invocations"
]
]
}
},
"MethodResponses": [
{
"StatusCode": 200,
"ResponseModels": {
"application/json": "userCreateResponse"
}
},
{
"StatusCode": 400,
"ResponseModels": {
"application/json": "userCreateResponse"
}
},
{
"StatusCode": 500,
"ResponseModels": {
"application/json": "userCreateResponse"
}
}
],
"RequestModels": {
"application/json": "userCreateRequest"
}
},
"DependsOn": [
"userCreateResponseModel",
"userCreateRequestModel"
]
},
Here's what it looks like for v0.5.6:
"ApiGatewayMethodUsersPost": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"HttpMethod": "POST",
"RequestParameters": {},
"ResourceId": {
"Ref": "ApiGatewayResourceUsers"
},
"RestApiId": {
"Ref": "ApiGatewayRestApi"
},
"AuthorizationType": "NONE",
"Integration": {
"IntegrationHttpMethod": "POST",
"Type": "AWS_PROXY",
"Uri": {
"Fn::Join": [
"",
[
"arn:aws:apigateway:",
{
"Ref": "AWS::Region"
},
":lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"ClientApiLambdaFunction",
"Arn"
]
},
"/invocations"
]
]
}
},
"MethodResponses": [],
"RequestModels": {
"application/json": "userCreateRequest"
}
},
"DependsOn": [
"userCreateRequestModel"
]
},
With no change to serverless.yml
in between. Just let me know if you need more information to reproduce this - I'm willing to send you my serverless.yml privately, I just don't know if publishing it publicly here will expose our project to any risk.
Thanks!
@dperjar, @cdichiara, I think I fixed it. Can you please have a look at #18? Would be cool if you can add the commit in this PR to your project and try it out. Hopefully this fixes your problems.
I'm working on a second project using the serverless-aws-documentation plugin
0.5.6
and running into an issue where response models are not being set for my serverless endpoints.Request models are present but the Responses object is missing when I "Export as Swagger" in API Gateway. All of my models have been imported in the "Models" section of API Gateway but the response models are not included in the Swagger file. There are no entries for "Method Response" when viewing the endpoint in the API Gateway Resources pane.
I've been able to use this plugin successfully on version
0.5.2
and downgraded to try that version, which worked. It set method responses successfully and the exported Swagger included my responses as expected. I haven't tested other versions .Here's the serverless.yml I'm using to produce the incorrect behavior on
0.5.6
... I've trimmed it down to just one endpoint in the process of debugging and for clarity.Here's the Swagger yaml exported after serverless deploy, note empty
responses: {}