From 1e5169e7d4d522057621a61c8dad272bacd8b953 Mon Sep 17 00:00:00 2001 From: jihndai <73680880+jihndai@users.noreply.github.com> Date: Mon, 7 Feb 2022 20:52:52 -0400 Subject: [PATCH] remove mapping to comply with draft-04 --- packages/@aws-cdk/aws-apigateway/lib/util.ts | 1 - .../@aws-cdk/aws-apigateway/test/util.test.ts | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-apigateway/lib/util.ts b/packages/@aws-cdk/aws-apigateway/lib/util.ts index 7facdc35bc2a0..eb7566a56ae0c 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/util.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/util.ts @@ -95,7 +95,6 @@ export class JsonSchemaMapper { private static readonly SchemaPropsWithPrefix: { [key: string]: string } = { schema: '$schema', ref: '$ref', - id: '$id', }; // The value indicates whether direct children should be key-mapped. private static readonly SchemaPropsWithUserDefinedChildren: { [key: string]: boolean } = { diff --git a/packages/@aws-cdk/aws-apigateway/test/util.test.ts b/packages/@aws-cdk/aws-apigateway/test/util.test.ts index 30861de05dad1..79ea5c60e9682 100644 --- a/packages/@aws-cdk/aws-apigateway/test/util.test.ts +++ b/packages/@aws-cdk/aws-apigateway/test/util.test.ts @@ -1,4 +1,4 @@ -import { JsonSchema, JsonSchemaType } from '../lib'; +import { JsonSchema, JsonSchemaType, JsonSchemaVersion } from '../lib'; import { JsonSchemaMapper, parseAwsApiCall, parseMethodOptionsPath } from '../lib/util'; describe('util', () => { @@ -136,5 +136,18 @@ describe('util', () => { default: 'blue', }); }); + + test('"id" maps to "id" when using DRAFT-04', () => { + const schema: JsonSchema = { + schema: JsonSchemaVersion.DRAFT4, + id: 'http://json-schema.org/draft-04/schema#', + }; + + const actual = JsonSchemaMapper.toCfnJsonSchema(schema); + expect(actual).toEqual({ + $schema: 'http://json-schema.org/draft-04/schema#', + id: 'http://json-schema.org/draft-04/schema#', + }); + }); }); });