serverless-aws-documentation
serverless-aws-documentation copied to clipboard
ERROR "Missing required key 'restApiId' in params"
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 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.
Thanks for your comment. I found the key in AWS API Gateway console, and use AWS CLI to download the Swagger template.
I had this error as well. I think it disappeared when I cleaned my node_modules and did a fresh install.
For me cleaning node_modules and running serverless deploy did not fix the issue. I don't know where this restApiId should be set?
Yeah, just discovered that this is still an issue as well
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.
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.
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