Table of Contents

Class JsonSchema

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll

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

public class JsonSchema : IJsonSchema
Inheritance
JsonSchema
Implements
Inherited Members

Examples

RestApi api;


             // We define the JSON Schema for the transformed valid response
             var responseModel = api.AddModel("ResponseModel", new ModelOptions {
                 ContentType = "application/json",
                 ModelName = "ResponseModel",
                 Schema = new JsonSchema {
                     Schema = JsonSchemaVersion.DRAFT4,
                     Title = "pollResponse",
                     Type = JsonSchemaType.OBJECT,
                     Properties = new Dictionary<string, JsonSchema> {
                         { "state", new JsonSchema { Type = JsonSchemaType.STRING } },
                         { "greeting", new JsonSchema { Type = JsonSchemaType.STRING } }
                     }
                 }
             });

             // We define the JSON Schema for the transformed error response
             var errorResponseModel = api.AddModel("ErrorResponseModel", new ModelOptions {
                 ContentType = "application/json",
                 ModelName = "ErrorResponseModel",
                 Schema = new JsonSchema {
                     Schema = JsonSchemaVersion.DRAFT4,
                     Title = "errorResponse",
                     Type = JsonSchemaType.OBJECT,
                     Properties = new Dictionary<string, JsonSchema> {
                         { "state", new JsonSchema { Type = JsonSchemaType.STRING } },
                         { "message", new JsonSchema { Type = JsonSchemaType.STRING } }
                     }
                 }
             });

Remarks

Copied from npm module jsonschema.

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

ExampleMetadata: infused

Constructors

JsonSchema()

public JsonSchema()

Properties

AdditionalItems

public IJsonSchema[]? AdditionalItems { get; set; }

Property Value

IJsonSchema[]

AdditionalProperties

public object? AdditionalProperties { get; set; }

Property Value

object

AllOf

public IJsonSchema[]? AllOf { get; set; }

Property Value

IJsonSchema[]

AnyOf

public IJsonSchema[]? AnyOf { get; set; }

Property Value

IJsonSchema[]

Contains

public object? Contains { get; set; }

Property Value

object

Default

The default value if you use an enum.

public object? Default { get; set; }

Property Value

object

Remarks

Default: - not set

Definitions

public IDictionary<string, IJsonSchema>? Definitions { get; set; }

Property Value

IDictionary<string, IJsonSchema>

Dependencies

public IDictionary<string, object>? Dependencies { get; set; }

Property Value

IDictionary<string, object>

Description

public string? Description { get; set; }

Property Value

string

Enum

public object[]? Enum { get; set; }

Property Value

object[]

ExclusiveMaximum

public bool? ExclusiveMaximum { get; set; }

Property Value

bool?

ExclusiveMinimum

public bool? ExclusiveMinimum { get; set; }

Property Value

bool?

Format

public string? Format { get; set; }

Property Value

string

Id

public string? Id { get; set; }

Property Value

string

Items

public object? Items { get; set; }

Property Value

object

MaxItems

public double? MaxItems { get; set; }

Property Value

double?

MaxLength

public double? MaxLength { get; set; }

Property Value

double?

MaxProperties

public double? MaxProperties { get; set; }

Property Value

double?

Maximum

public double? Maximum { get; set; }

Property Value

double?

MinItems

public double? MinItems { get; set; }

Property Value

double?

MinLength

public double? MinLength { get; set; }

Property Value

double?

MinProperties

public double? MinProperties { get; set; }

Property Value

double?

Minimum

public double? Minimum { get; set; }

Property Value

double?

MultipleOf

public double? MultipleOf { get; set; }

Property Value

double?

Not

public IJsonSchema? Not { get; set; }

Property Value

IJsonSchema

OneOf

public IJsonSchema[]? OneOf { get; set; }

Property Value

IJsonSchema[]

Pattern

public string? Pattern { get; set; }

Property Value

string

PatternProperties

public IDictionary<string, IJsonSchema>? PatternProperties { get; set; }

Property Value

IDictionary<string, IJsonSchema>

Properties

public IDictionary<string, IJsonSchema>? Properties { get; set; }

Property Value

IDictionary<string, IJsonSchema>

PropertyNames

public IJsonSchema? PropertyNames { get; set; }

Property Value

IJsonSchema

Ref

public string? Ref { get; set; }

Property Value

string

Required

public string[]? Required { get; set; }

Property Value

string[]

Schema

public JsonSchemaVersion? Schema { get; set; }

Property Value

JsonSchemaVersion?

Title

public string? Title { get; set; }

Property Value

string

Type

public object? Type { get; set; }

Property Value

object

UniqueItems

public bool? UniqueItems { get; set; }

Property Value

bool?