serverless-aws-documentation icon indicating copy to clipboard operation
serverless-aws-documentation copied to clipboard

ERROR "Missing required key 'restApiId' in params"

Open trantien489 opened this issue 7 years ago • 8 comments
trafficstars

Hi Authors,

I face the issue when try to run command "serverless downloadDocumentation --outputFileName=filename.ext". This error is "Missing required key 'restApiId' in params". I created a API key in AWS API Gateway and add the API key to command --restApiId , but still not pass the issue.

My environment:

  • Serverless : 1.32.0
  • Serverless-aws-documentation : 1.1.0

I have researched but I haven't found the solution. I'm very gatefull if someone can help me.

Thanks!

trantien489 avatar Oct 15 '18 11:10 trantien489

@trantien489 I just ran into this same issue and it turns out the running the serverless deploy prior to running serverless downloadDocumentation --outputFileName=filename.ext makes the error go away. I'm guessing the documentation plugin is getting some context from the resources generated during a deploy.

Let me know if that helps.

jonlazz avatar Nov 07 '18 23:11 jonlazz

Thanks for your comment. I found the key in AWS API Gateway console, and use AWS CLI to download the Swagger template.

trantien489 avatar Nov 08 '18 03:11 trantien489

I had this error as well. I think it disappeared when I cleaned my node_modules and did a fresh install.

joextodd avatar Oct 18 '19 08:10 joextodd

For me cleaning node_modules and running serverless deploy did not fix the issue. I don't know where this restApiId should be set?

GoGoris avatar Jan 26 '20 14:01 GoGoris

Yeah, just discovered that this is still an issue as well

svdgraaf avatar Jan 29 '20 07:01 svdgraaf

I see that the problem arises from downloadDocumentation.js:

return this.serverless.providers.aws.request('CloudFormation', 'describeStacks', {StackName: stackName},
      this.serverless.service.provider.stage,
      this.serverless.service.provider.region
    )
Serverless: WARNING: Inappropriate call of provider.request()

This will return undefined, and it will fail from there. I'll do my best to see if I can create a PR for this.

svdgraaf avatar Jan 29 '20 08:01 svdgraaf

I see it's trying to fetch a custom stack output AwsDocApiId, which is set by itself. I'm guessing that I'm missing that value in my stack outputs, as it's not currently present in my target stack.

svdgraaf avatar Jan 29 '20 08:01 svdgraaf

In my case, I think I ran into the error because we have an entire Serverless project just for creating the API Gateway itself, and it includes none of the Lambda functions (for various reasons). that's why (I think) the downloadDocumentation command didn't work.

In the end, it didn't matter as I simply needed to download the swagger.json file. I went the same route as @trantien489 above and used the AWS API Gateway CLI's get-export function to download the documentation directly.

A simple script in package.json did the trick: aws apigateway get-export --profile dev --region us-east-1 --rest-api-id {MY_API_ID} --stage-name dev --export-type swagger --parameters extensions='postman' swagger.json

pflugs30 avatar Feb 20 '20 17:02 pflugs30