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
111 lines (93 loc) · 4.9 KB

File metadata and controls

111 lines (93 loc) · 4.9 KB

ObjectWithDecimalProperties

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

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 ObjectWithDecimalProperties.ObjectWithDecimalProperties1
schema class
static class ObjectWithDecimalProperties.ObjectWithDecimalPropertiesMap
output class for Map payloads
static class ObjectWithDecimalProperties.Width
schema class

ObjectWithDecimalProperties1

public static class ObjectWithDecimalProperties1
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
ObjectWithDecimalProperties.ObjectWithDecimalPropertiesMap validatedPayload =
    ObjectWithDecimalProperties.ObjectWithDecimalProperties1.validate(
    MapMaker.makeMap(
        new AbstractMap.SimpleEntry<>(
            "length",
            "3.14"
        ),
        new AbstractMap.SimpleEntry<>(
            "width",
            "3.14"
        ),
        new AbstractMap.SimpleEntry<>(
            "cost",
            MapMaker.makeMap(
                new AbstractMap.SimpleEntry<>(
                    "amount",
                    "3.14"
                ),
                new AbstractMap.SimpleEntry<>(
                    "currency",
                    "eur"
                )
            )
        )
    ),
    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("length", DecimalPayload.DecimalPayload1.class),
        new PropertyEntry("width", Width.class)),
        new PropertyEntry("cost", Money.Money1.class)
    )))
));

Method Summary

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

ObjectWithDecimalPropertiesMap

public static class ObjectWithDecimalPropertiesMap
extends FrozenMap<String, Object>

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static ObjectWithDecimalPropertiesMap of(Map<String, Object> arg, SchemaConfiguration configuration)
String length()
[optional]
String width()
[optional] value must be int or float numeric
Money.MoneyMap cost()
[optional]
Object getAdditionalProperty(String name)
provides type safety for additional properties

Input Map Keys

type: Map<String, Object>
Key Type Description Notes
length String [optional]
width String [optional] value must be int or float numeric
cost Map<String, Object> [optional]
anyStringName Object any string name can be used but the value must be the correct type [optional]

Width

public static class Width
extends DecimalJsonSchema

A schema class that validates payloads

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

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