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

Latest commit

 

History

History
128 lines (106 loc) · 6.65 KB

File metadata and controls

128 lines (106 loc) · 6.65 KB

ObjectWithDecimalProperties

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

A class that contains necessary nested

  • schema classes (which validate payloads), extends JsonSchema
  • classes to store validated map payloads, extends FrozenMap
  • classes to build inputs for map payloads

Nested Class Summary

Modifier and Type Class and Description
static class ObjectWithDecimalProperties.ObjectWithDecimalProperties1
schema class
static class ObjectWithDecimalProperties.ObjectWithDecimalPropertiesMapBuilder
builder for Map payloads
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.validation.MapUtils;
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(
    new ObjectWithDecimalProperties.ObjectWithDecimalPropertiesMapBuilder()
        .length("3.14")

        .width("3.14")

        .cost(
            MapUtils.makeMap(
                new AbstractMap.SimpleEntry<String, String>(
                    "amount",
                    "3.14"
                ),
                new AbstractMap.SimpleEntry<String, String>(
                    "currency",
                    "eur"
                )
            )
        )
    .build(),
    configuration
);

Field Summary

Modifier and Type Field and Description
Set<Class<?>> type = Set.of(Map.class)
Map<String, Class<? extends JsonSchema>> properties = 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
ObjectWithDecimalPropertiesMap validate(Map<?, ?> arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

ObjectWithDecimalPropertiesMapBuilder

public class ObjectWithDecimalPropertiesMapBuilder
builder for Map<String, @Nullable Object>

A class that builds the Map input type

Constructor Summary

Constructor and Description
ObjectWithDecimalPropertiesMapBuilder()
Creates a builder that contains an empty map

Method Summary

Modifier and Type Method and Description
Map<String, @Nullable Object> build()
Returns map input that should be used with Schema.validate
ObjectWithDecimalPropertiesMapBuilder length(String value)
ObjectWithDecimalPropertiesMapBuilder width(String value)
ObjectWithDecimalPropertiesMapBuilder cost(Map<String, @Nullable Object> value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, Void value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, boolean value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, String value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, int value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, float value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, long value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, double value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, List<?> value)
ObjectWithDecimalPropertiesMapBuilder additionalProperty(String key, Map<String, ?> value)

ObjectWithDecimalPropertiesMap

public static class ObjectWithDecimalPropertiesMap
extends FrozenMap<String, @Nullable Object>

A class to store validated Map payloads

Method Summary

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

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]