# JsonSchema

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

Copied from npm module jsonschema.

- Source: [`aws-apigateway/lib/json-schema.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-apigateway/lib/json-schema.ts#L27)
- Type last changed: v2.201.0 · 13 Jun 2025

## Example

```ts
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

- `additionalItems`: boolean | [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)

- `additionalProperties`: boolean | [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)

- `allOf`: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)[]

- `anyOf`: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)[]

- `contains`: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html) | [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)[]

- `default`: any — The default value if you use an enum.

  **Default:** not set

- `definitions`: { [key: string]: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html) }

- `dependencies`: { [key: string]: string[] | [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html) }

- `description`: string

- `enum`: any[]

- `exclusiveMaximum`: boolean

- `exclusiveMinimum`: boolean

- `format`: string

- `id`: string

- `items`: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html) | [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)[]

- `maximum`: number

- `maxItems`: number

- `maxLength`: number

- `maxProperties`: number

- `minimum`: number

- `minItems`: number

- `minLength`: number

- `minProperties`: number

- `multipleOf`: number

- `not`: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)

- `oneOf`: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)[]

- `pattern`: string

- `patternProperties`: { [key: string]: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html) }

- `properties`: { [key: string]: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html) }

- `propertyNames`: [JsonSchema](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchema.html)

- `ref`: string

- `required`: string[]

- `schema`: [JsonSchemaVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchemaVersion.html)

- `title`: string

- `type`: [JsonSchemaType](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchemaType.html) | [JsonSchemaType](/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.JsonSchemaType.html)[]

- `uniqueItems`: boolean
