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

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

5deb73a · Dec 6, 2023

History

History
206 lines (167 loc) · 8.56 KB

File metadata and controls

206 lines (167 loc) · 8.56 KB

Order

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

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 Order.Order1
schema class
static class Order.OrderMap
output class for Map payloads
static class Order.Complete
schema class
static class Order.Status
schema class
static class Order.ShipDate
schema class
static class Order.Quantity
schema class
static class Order.PetId
schema class
static class Order.Id
schema class

Order1

public static class Order1
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
Order.OrderMap validatedPayload =
    Order.Order1.validate(
    MapMaker.makeMap(
        new AbstractMap.SimpleEntry<>(
            "id",
            1L
        ),
        new AbstractMap.SimpleEntry<>(
            "petId",
            1L
        ),
        new AbstractMap.SimpleEntry<>(
            "quantity",
            1
        ),
        new AbstractMap.SimpleEntry<>(
            "shipDate",
            "1970-01-01T00:00:00.00Z"
        ),
        new AbstractMap.SimpleEntry<>(
            "status",
            "placed"
        ),
        new AbstractMap.SimpleEntry<>(
            "complete",
            true
        )
    ),
    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("id", Id.class)),
        new PropertyEntry("petId", PetId.class)),
        new PropertyEntry("quantity", Quantity.class)),
        new PropertyEntry("shipDate", ShipDate.class)),
        new PropertyEntry("status", Status.class)),
        new PropertyEntry("complete", Complete.class))
    )))
));

Method Summary

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

OrderMap

public static class OrderMap
extends FrozenMap<String, Object>

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static OrderMap of(Map<String, Object> arg, SchemaConfiguration configuration)
long id()
[optional] value must be a 64 bit integer
long petId()
[optional] value must be a 64 bit integer
int quantity()
[optional] value must be a 32 bit integer
String shipDate()
[optional] value must conform to RFC-3339 date-time
String status()
[optional] must be one of ["placed", "approved", "delivered"]
boolean complete()
[optional] if omitted the server will use the default value of false
Object getAdditionalProperty(String name)
provides type safety for additional properties

Input Map Keys

type: Map<String, Object>
Key Type Description Notes
id long [optional] value must be a 64 bit integer
petId long [optional] value must be a 64 bit integer
quantity int [optional] value must be a 32 bit integer
shipDate String [optional] value must conform to RFC-3339 date-time
status String Order Status [optional] must be one of ["placed", "approved", "delivered"]
complete boolean [optional] if omitted the server will use the default value of false
anyStringName Object any string name can be used but the value must be the correct type [optional]

Complete

public static class Complete
extends BooleanJsonSchema

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.BooleanJsonSchema
validate

Status

public static class Status
extends JsonSchema

A schema class that validates payloads

Description

Order Status

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());

// String validation
String validatedPayload = Order.Status.validate(
    "placed",
    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(
        String.class
    ))),
    new KeywordEntry("enum", new EnumValidator(Set.of(
        "placed",
        "approved",
        "delivered"
)))
));

Method Summary

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

ShipDate

public static class ShipDate
extends DateTimeJsonSchema

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.DateTimeJsonSchema
validate

Quantity

public static class Quantity
extends Int32JsonSchema

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.Int32JsonSchema
validate

PetId

public static class PetId
extends Int64JsonSchema

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.Int64JsonSchema
validate

Id

public static class Id
extends Int64JsonSchema

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.Int64JsonSchema
validate

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