通过http请求从api网关导出swagger api定义? [英] export swagger api definition from api gateway via http request?

查看:290
本文介绍了通过http请求从api网关导出swagger api定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据AWS文档使用以下http请求从api网关导出api定义.知道为什么它不起作用吗?

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"

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

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

推荐答案

我建议您改用aws cli导出大张旗鼓(

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).

如果要使用curl命令导出大张旗鼓,则需要使用SigV4签署请求(

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"

这篇关于通过http请求从api网关导出swagger api定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆