JsonSchema

class aws_cdk.aws_apigateway.JsonSchema(*, additional_items=None, additional_properties=None, all_of=None, any_of=None, contains=None, default=None, definitions=None, dependencies=None, description=None, enum=None, exclusive_maximum=None, exclusive_minimum=None, format=None, id=None, items=None, maximum=None, max_items=None, max_length=None, max_properties=None, minimum=None, min_items=None, min_length=None, min_properties=None, multiple_of=None, not_=None, one_of=None, pattern=None, pattern_properties=None, properties=None, property_names=None, ref=None, required=None, schema=None, title=None, type=None, unique_items=None)

Bases: object

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

Copied from npm module jsonschema.

Parameters
  • additional_items (Optional[Sequence[Union[JsonSchema, Dict[str, Any]]]]) –

  • additional_properties (Union[bool, JsonSchema, Dict[str, Any], None]) –

  • all_of (Optional[Sequence[Union[JsonSchema, Dict[str, Any]]]]) –

  • any_of (Optional[Sequence[Union[JsonSchema, Dict[str, Any]]]]) –

  • contains (Union[JsonSchema, Dict[str, Any], Sequence[Union[JsonSchema, Dict[str, Any]]], None]) –

  • default (Optional[Any]) – The default value if you use an enum. Default: - not set

  • definitions (Optional[Mapping[str, Union[JsonSchema, Dict[str, Any]]]]) –

  • dependencies (Optional[Mapping[str, Union[Sequence[str], JsonSchema, Dict[str, Any]]]]) –

  • description (Optional[str]) –

  • enum (Optional[Sequence[Any]]) –

  • exclusive_maximum (Optional[bool]) –

  • exclusive_minimum (Optional[bool]) –

  • format (Optional[str]) –

  • id (Optional[str]) –

  • items (Union[JsonSchema, Dict[str, Any], Sequence[Union[JsonSchema, Dict[str, Any]]], None]) –

  • maximum (Union[int, float, None]) –

  • max_items (Union[int, float, None]) –

  • max_length (Union[int, float, None]) –

  • max_properties (Union[int, float, None]) –

  • minimum (Union[int, float, None]) –

  • min_items (Union[int, float, None]) –

  • min_length (Union[int, float, None]) –

  • min_properties (Union[int, float, None]) –

  • multiple_of (Union[int, float, None]) –

  • not

  • one_of (Optional[Sequence[Union[JsonSchema, Dict[str, Any]]]]) –

  • pattern (Optional[str]) –

  • pattern_properties (Optional[Mapping[str, Union[JsonSchema, Dict[str, Any]]]]) –

  • properties (Optional[Mapping[str, Union[JsonSchema, Dict[str, Any]]]]) –

  • property_names (Union[JsonSchema, Dict[str, Any], None]) –

  • ref (Optional[str]) –

  • required (Optional[Sequence[str]]) –

  • schema (Optional[JsonSchemaVersion]) –

  • title (Optional[str]) –

  • type (Union[JsonSchemaType, Sequence[JsonSchemaType], None]) –

  • unique_items (Optional[bool]) –

See

https://github.com/tdegrunt/jsonschema

ExampleMetadata

infused

Example:

# api: apigateway.RestApi


# We define the JSON Schema for the transformed valid response
response_model = api.add_model("ResponseModel",
    content_type="application/json",
    model_name="ResponseModel",
    schema=apigateway.JsonSchema(
        schema=apigateway.JsonSchemaVersion.DRAFT4,
        title="pollResponse",
        type=apigateway.JsonSchemaType.OBJECT,
        properties={
            "state": apigateway.JsonSchema(type=apigateway.JsonSchemaType.STRING),
            "greeting": apigateway.JsonSchema(type=apigateway.JsonSchemaType.STRING)
        }
    )
)

# We define the JSON Schema for the transformed error response
error_response_model = api.add_model("ErrorResponseModel",
    content_type="application/json",
    model_name="ErrorResponseModel",
    schema=apigateway.JsonSchema(
        schema=apigateway.JsonSchemaVersion.DRAFT4,
        title="errorResponse",
        type=apigateway.JsonSchemaType.OBJECT,
        properties={
            "state": apigateway.JsonSchema(type=apigateway.JsonSchemaType.STRING),
            "message": apigateway.JsonSchema(type=apigateway.JsonSchemaType.STRING)
        }
    )
)

Attributes

additional_items
additional_properties
all_of
any_of
contains
default

The default value if you use an enum.

Default
  • not set

definitions
dependencies
description
enum
exclusive_maximum
exclusive_minimum
format
id
items
max_items
max_length
max_properties
maximum
min_items
min_length
min_properties
minimum
multiple_of
not_
one_of
pattern
pattern_properties
properties
property_names
ref
required
schema
title
type
unique_items