export swagger api definition from api gateway via http request?

此生再无相见时 提交于 2019-12-23 02:51:01

问题


I am trying to export api definition from api gateway using the following http request following the documentation of AWS. Any idea why is it not working?

curl -i -X GET -H "Accept: application/json" "https://apigateway.ap-northeast-1.amazonaws.com/restapis/<api-id>/stages/<stage-name>/exports/swagger"

Error: HTTP/1.1 403 Forbidden {"message":"Missing Authentication Token"}


回答1:


I would recommend that you use the aws cli for exporting swagger instead (http://docs.aws.amazon.com/cli/latest/reference/apigateway/get-export.html).

If you want to use a curl command to export swagger, you will need to sign the request with SigV4 (http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html?shortFooter=true) . I was able export a swagger successfully with the below command

curl -X GET -H "Accept: application/json" -H "Host: apigateway.us-east-1.amazonaws.com" -H "Authorization: AWS4-HMAC-SHA256 Credential=<ACCESS_ID>/20160616/us-east-1/apigateway/aws4_request, SignedHeaders=accept;content-type;host;x-amz-date, Signature=<SIG_V4_SIGNATURE>" -H "Content-Type: application/x-www-form-urlencoded" -H "X-Amz-Date: 20160616T173231Z" -H "Cache-Control: no-cache" "https://apigateway.us-east-1.amazonaws.com/restapis/<REST_API_ID>/stages/<STAGE_NAME>/exports/swagger"


来源:https://stackoverflow.com/questions/37855489/export-swagger-api-definition-from-api-gateway-via-http-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!