aws-cdk-lib.aws_apigateway.JsonSchema

interface JsonSchema

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.JsonSchema
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#JsonSchema
Javasoftware.amazon.awscdk.services.apigateway.JsonSchema
Pythonaws_cdk.aws_apigateway.JsonSchema
TypeScript (source)aws-cdk-lib » aws_apigateway » JsonSchema

Represents a JSON schema definition of the structure of a REST API model.

Copied from npm module jsonschema.

See also: https://github.com/tdegrunt/jsonschema

Example

declare const api: apigateway.RestApi;

// We define the JSON Schema for the transformed valid response
const responseModel = api.addModel('ResponseModel', {
  contentType: 'application/json',
  modelName: 'ResponseModel',
  schema: {
    schema: apigateway.JsonSchemaVersion.DRAFT4,
    title: 'pollResponse',
    type: apigateway.JsonSchemaType.OBJECT,
    properties: {
      state: { type: apigateway.JsonSchemaType.STRING },
      greeting: { type: apigateway.JsonSchemaType.STRING }
    }
  }
});

// We define the JSON Schema for the transformed error response
const errorResponseModel = api.addModel('ErrorResponseModel', {
  contentType: 'application/json',
  modelName: 'ErrorResponseModel',
  schema: {
    schema: apigateway.JsonSchemaVersion.DRAFT4,
    title: 'errorResponse',
    type: apigateway.JsonSchemaType.OBJECT,
    properties: {
      state: { type: apigateway.JsonSchemaType.STRING },
      message: { type: apigateway.JsonSchemaType.STRING }
    }
  }
});

Properties

NameTypeDescription
additionalItems?JsonSchema[]
additionalProperties?boolean | JsonSchema
allOf?JsonSchema[]
anyOf?JsonSchema[]
contains?JsonSchema | JsonSchema[]
default?anyThe default value if you use an enum.
definitions?{ [string]: JsonSchema }
dependencies?{ [string]: string[] | JsonSchema }
description?string
enum?any[]
exclusiveMaximum?boolean
exclusiveMinimum?boolean
format?string
id?string
items?JsonSchema | JsonSchema[]
maxItems?number
maxLength?number
maxProperties?number
maximum?number
minItems?number
minLength?number
minProperties?number
minimum?number
multipleOf?number
not?JsonSchema
oneOf?JsonSchema[]
pattern?string
patternProperties?{ [string]: JsonSchema }
properties?{ [string]: JsonSchema }
propertyNames?JsonSchema
ref?string
required?string[]
schema?JsonSchemaVersion
title?string
type?JsonSchemaType | JsonSchemaType[]
uniqueItems?boolean

additionalItems?

Type: JsonSchema[] (optional)


additionalProperties?

Type: boolean | JsonSchema (optional)


allOf?

Type: JsonSchema[] (optional)


anyOf?

Type: JsonSchema[] (optional)


contains?

Type: JsonSchema | JsonSchema[] (optional)


default?

Type: any (optional, default: not set)

The default value if you use an enum.


definitions?

Type: { [string]: JsonSchema } (optional)


dependencies?

Type: { [string]: string[] | JsonSchema } (optional)


description?

Type: string (optional)


enum?

Type: any[] (optional)


exclusiveMaximum?

Type: boolean (optional)


exclusiveMinimum?

Type: boolean (optional)


format?

Type: string (optional)


id?

Type: string (optional)


items?

Type: JsonSchema | JsonSchema[] (optional)


maxItems?

Type: number (optional)


maxLength?

Type: number (optional)


maxProperties?

Type: number (optional)


maximum?

Type: number (optional)


minItems?

Type: number (optional)


minLength?

Type: number (optional)


minProperties?

Type: number (optional)


minimum?

Type: number (optional)


multipleOf?

Type: number (optional)


not?

Type: JsonSchema (optional)


oneOf?

Type: JsonSchema[] (optional)


pattern?

Type: string (optional)


patternProperties?

Type: { [string]: JsonSchema } (optional)


properties?

Type: { [string]: JsonSchema } (optional)


propertyNames?

Type: JsonSchema (optional)


ref?

Type: string (optional)


required?

Type: string[] (optional)


schema?

Type: JsonSchemaVersion (optional)


title?

Type: string (optional)


type?

Type: JsonSchemaType | JsonSchemaType[] (optional)


uniqueItems?

Type: boolean (optional)