当我从swagger导入yaml时,授权器不起作用,在删除并重新添加后,它可以正常工作

时间:2017-06-03 01:12:39

标签: amazon-web-services aws-api-gateway swagger-2.0

我在调用我的服务之前使用自定义授权程序和api网关来提升用户的注意力。首先,我手动创建所有资源和方法,然后创建授权程序并在方法执行中将服务附加到授权程序。 当我部署我的api网关时一切正常,当我用api网关扩展导出yaml文件时,我有以下yaml文件

---
swagger: "2.0"
info:
 version: "2017-06-02T19:36:38Z"
 title: "test"
 host: "t8ksrbnwce.execute-api.us-east-1.amazonaws.com"
 basePath: "/rrr"
 schemes:
  - "https"
 paths:
   /stories/{storyid}:
   get:
  produces:
  - "application/json"
  parameters:
  - name: "storyid"
    in: "path"
    required: true
    type: "string"
  responses:
    200:
      description: "200 response"
      schema:
        $ref: "#/definitions/Empty"
      headers:
        Access-Control-Allow-Origin:
          type: "string"
  security:
  - userAthenticationCheck: []
  x-amazon-apigateway-integration:
    responses:
      default:
        statusCode: "200"
        responseParameters:
          method.response.header.Access-Control-Allow-Origin: "'*'"
    requestParameters:
      integration.request.path.id: "method.request.path.storyid"
    uri: "https://jsonplaceholder.typicode.com/posts/{id}"
    passthroughBehavior: "when_no_match"
    httpMethod: "GET"
    type: "http"
options:
  consumes:
  - "application/json"
  produces:
  - "application/json"
  responses:
    200:
      description: "200 response"
      schema:
        $ref: "#/definitions/Empty"
      headers:
        Access-Control-Allow-Origin:
          type: "string"
        Access-Control-Allow-Methods:
          type: "string"
        Access-Control-Allow-Headers:
          type: "string"
  x-amazon-apigateway-integration:
    responses:
      default:
        statusCode: "200"
        responseParameters:
          method.response.header.Access-Control-Allow-Methods: 
   "'GET,OPTIONS'"
          method.response.header.Access-Control-Allow-Headers: "'Content-
         Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,Access-Control-
  Allow-Headers,Origin,X-Requested-With,Accept,authorizationToken'"
          method.response.header.Access-Control-Allow-Origin: "'*'"
    requestTemplates:
      application/json: "{\"statusCode\": 200}"
    passthroughBehavior: "when_no_match"
    type: "mock"
    securityDefinitions:
    userAthenticationCheck:
     type: "apiKey"
     name: "authorizationToken"
    in: "header"
   x-amazon-apigateway-authtype: "custom"
    x-amazon-apigateway-authorizer:
  authorizerUri: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-
   31/functions/arn:aws:lambda:us-east-
 1:048947288163:function:Authorizer/invocations"
  authorizerResultTtlInSeconds: 0
  type: "token"
  definitions:
  Empty:
    type: "object"
    title: "Empty Schema"

现在我有了yaml文件,我想在任何需要的时候导入它。 但是,当我再次导入yaml文件时,当我使用postman尝试导入的API网关时,我得到cors 500错误。然后,当我删除api网关的authorizer部分中的authorizer并再次使用相同的名称创建它时,它再次开始工作。但问题是我需要自动执行此过程,我不想再次手动删除和添加授权程序。任何人都可以帮忙解决这个问题吗?它是aws中的一个bug吗?或者我错过了吗?

1 个答案:

答案 0 :(得分:1)

道歉你正面临这个问题。

现在有一个错误导致现有授权者的引用在导入时被破坏。我不确定它是否会影响所有用例或子集,但显然它会影响到你。我们正在努力尽快解决此问题。

谢谢, 千斤顶