Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Latest commit

 

History

History
147 lines (120 loc) · 6.13 KB

File metadata and controls

147 lines (120 loc) · 6.13 KB

Drawing

org.openapijsonschematools.client.components.schemas.Drawing.java public class Drawing

A class that contains necessary nested schema classes, and classes to store validated list and map payloads

Nested Class Summary

Modifier and Type Class and Description
static class Drawing.Drawing1
schema class
static class Drawing.DrawingMap
output class for Map payloads
static class Drawing.Shapes
schema class
static class Drawing.ShapesList
output class for List payloads

Drawing1

public static class Drawing1
extends JsonSchema

A schema class that validates payloads

Code Sample

import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags;
import org.openapijsonschematools.client.configurations.SchemaConfiguration;
import org.openapijsonschematools.client.exceptions.ValidationException;
import org.openapijsonschematools.client.schemas.MapMaker;
import org.openapijsonschematools.client.schemas.validation.FrozenList;
import org.openapijsonschematools.client.schemas.validation.FrozenMap;

import java.util.Arrays;
import java.util.List;
import java.util.AbstractMap;

static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());

// Map validation
Drawing.DrawingMap validatedPayload =
    Drawing.Drawing1.validate(
    MapMaker.makeMap(
        new AbstractMap.SimpleEntry<>(
            "shapes",
            Arrays.asList(
            )
        )
    ),
    configuration
);

Field Summary

Modifier and Type Field and Description
static LinkedHashMap<String, KeywordValidator> keywordToValidator
new LinkedHashMap<>(Map.ofEntries(
    new KeywordEntry("type", new TypeValidator(Set.of(FrozenMap.class))),
    new KeywordEntry("properties", new PropertiesValidator(Map.ofEntries(
        new PropertyEntry("mainShape", Shape.Shape1.class),
        new PropertyEntry("shapeOrNull", ShapeOrNull.ShapeOrNull1.class),
        new PropertyEntry("nullableShape", NullableShape.NullableShape1.class),
        new PropertyEntry("shapes", Shapes.class))
    ))),
    new KeywordEntry("additionalProperties", new AdditionalPropertiesValidator(Fruit.Fruit1.class)
));

Method Summary

Modifier and Type Method and Description
static DrawingMap validate(Map<String, Object> arg, SchemaConfiguration configuration)

DrawingMap

public static class DrawingMap
extends FrozenMap<String, Object>

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static DrawingMap of(Map<String, Object> arg, SchemaConfiguration configuration)
Object mainShape()
[optional]
Object shapeOrNull()
[optional]
Object nullableShape()
[optional]
ShapesList shapes()
[optional]
Object getAdditionalProperty(String name)
provides type safety for additional properties

Input Map Keys

type: Map<String, Object>
Key Type Description Notes
mainShape Object [optional]
shapeOrNull Object [optional]
nullableShape Object [optional]
shapes List [optional]
anyStringName Object any string name can be used but the value must be the correct type [optional]

Shapes

public static class Shapes
extends JsonSchema

A schema class that validates payloads

Code Sample

import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags;
import org.openapijsonschematools.client.configurations.SchemaConfiguration;
import org.openapijsonschematools.client.exceptions.ValidationException;
import org.openapijsonschematools.client.schemas.MapMaker;
import org.openapijsonschematools.client.schemas.validation.FrozenList;
import org.openapijsonschematools.client.schemas.validation.FrozenMap;

import java.util.Arrays;
import java.util.List;
import java.util.AbstractMap;

static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());

// List validation
Drawing.ShapesList validatedPayload =
    Drawing.Shapes.validate(
    Arrays.asList(
    ),
    configuration
);

Field Summary

Modifier and Type Field and Description
static LinkedHashMap<String, KeywordValidator> keywordToValidator
new LinkedHashMap<>(Map.ofEntries(
    new KeywordEntry("type", new TypeValidator(Set.of(FrozenList.class))),
    new KeywordEntry("items", new ItemsValidator(Shape.Shape1.class)
));

Method Summary

Modifier and Type Method and Description
static ShapesList validate(List arg, SchemaConfiguration configuration)

ShapesList

public class ShapesList
extends FrozenList<Object>

A class to store validated List payloads

Method Summary

Modifier and Type Method and Description
static ShapesList of(List arg, SchemaConfiguration configuration)

Input List Items

type: List<Object>
List Item Type Description Notes
Object

[Back to top] [Back to Component Schemas] [Back to README]