我已经在OpenApi3中创建了一个简单的API网关定义:
openapi: "3.0.1"
info:
title: "FooApi"
version: "2018-12-20T16:48:35Z"
servers:
- url: "https://<id>.execute-api.us-east-1.amazonaws.com/{basePath}"
variables:
basePath:
default: "/test"
paths:
/foo:
get:
responses:
200:
description: "200 response"
content:
application/json:
schema:
$ref: "#/components/schemas/Foo"
x-amazon-apigateway-integration:
responses:
default:
statusCode: "200"
responseTemplates:
application/json: "{\"bar\": 123,\"baz\": 456}"
requestTemplates:
application/json: "{\"statusCode\": 200}"
passthroughBehavior: "when_no_match"
type: "mock"
components:
schemas:
Foo:
required:
- "bar"
type: "object"
properties:
bar:
type: "integer"
format: "int32"
additionalProperties: false
我希望这里会失败,因为返回的对象与为其指定的架构(模型)不匹配(有一个额外的属性,该架构明确禁止该属性)。但是,这不会发生-它返回具有额外属性的对象。
我似乎找不到在API Gateway中启用响应验证或类似功能的方法,所以我的问题是: