Aws api gate включает cors через api - PullRequest
0 голосов
/ 28 января 2019

Я пытаюсь включить cors через api, используя синтаксис swagger из примера, приведенного в aws https://docs.aws.amazon.com/apigateway/latest/developerguide/enable-cors-for-resource-using-swagger-importer-tool.html

Но это только первые опции ...

/users 
options:
  summary: CORS support
  description: |
    Enable CORS by returning correct headers
  consumes:
    - application/json
  produces:
    - application/json
  tags:
    - CORS
  x-amazon-apigateway-integration:
    type: mock
    requestTemplates:
      application/json: |
        {
          "statusCode" : 200
        }
    responses:
      "default":
        statusCode: "200"
        responseParameters:
          method.response.header.Access-Control-Allow-Headers : "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
          method.response.header.Access-Control-Allow-Methods : "'*'"
          method.response.header.Access-Control-Allow-Origin : "'*'"
        responseTemplates:
          application/json: |
            {}
  responses:
    200:
      description: Default response for CORS method
      headers:
        Access-Control-Allow-Headers:
          type: "string"
        Access-Control-Allow-Methods:
          type: "string"
        Access-Control-Allow-Origin:
          type: "string"

ниже не будет

/users 
options:
  summary: CORS support
  description: |
    Enable CORS by returning correct headers
  consumes:
    - application/json
  produces:
    - application/json
  tags:
    - CORS
  x-amazon-apigateway-integration:
    type: mock
    requestTemplates:
      application/json: |
        {
          "statusCode" : 200
        }
    responses:
      "default":
        statusCode: "200"
        responseParameters:
          method.response.header.Access-Control-Allow-Headers : "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
          method.response.header.Access-Control-Allow-Methods : "'*'"
          method.response.header.Access-Control-Allow-Origin : "'*'"
        responseTemplates:
          application/json: |
            {}
  responses:
    200:
      description: Default response for CORS method
      headers:
        Access-Control-Allow-Headers:
          type: "string"
        Access-Control-Allow-Methods:
          type: "string"
        Access-Control-Allow-Origin:
          type: "string"
 /users/{id} 
 options:
  summary: CORS support
  description: |
    Enable CORS by returning correct headers
  consumes:
    - application/json
  produces:
    - application/json
  tags:
    - CORS
  x-amazon-apigateway-integration:
    type: mock
    requestTemplates:
      application/json: |
        {
          "statusCode" : 200
        }
    responses:
      "default":
        statusCode: "200"
        responseParameters:
          method.response.header.Access-Control-Allow-Headers : "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'"
          method.response.header.Access-Control-Allow-Methods : "'*'"
          method.response.header.Access-Control-Allow-Origin : "'*'"
        responseTemplates:
          application/json: |
            {}
  responses:
    200:
      description: Default response for CORS method
      headers:
        Access-Control-Allow-Headers:
          type: "string"
        Access-Control-Allow-Methods:
          type: "string"
        Access-Control-Allow-Origin:
          type: "string"
...