Amazon web services 当我从swagger导入yaml时,授权人不起作用,在删除并重新添加yaml后,它起作用

Amazon web services 当我从swagger导入yaml时,授权人不起作用,在删除并重新添加yaml后,它起作用,amazon-web-services,aws-api-gateway,swagger-2.0,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.c

在调用我的服务之前,我使用自定义授权器和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吗?还是我遗漏了什么?

很抱歉,你面对这个问题

现在有一个bug导致导入时对现有授权者的引用被破坏。我不确定它是否会影响所有用例或子集,但很明显它会影响您。我们正在努力尽快解决这个问题

谢谢,
杰克

压痕错误。缩进实际上是这样的,还是只是复制粘贴错误?@Helen这只是复制并粘贴在yamle文件中缩进是正确的我在AWS论坛帖子上回答。