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

Latest commit

 

History

History
187 lines (152 loc) · 9.63 KB

File metadata and controls

187 lines (152 loc) · 9.63 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
  • sealed interfaces which store validated payloads, java version of a sum type
  • boxed classes which store validated payloads, sealed permits class implementations
  • classes to store validated map payloads, extends FrozenMap
  • classes to build inputs for map payloads

Nested Class Summary

Modifier and Type Class and Description
sealed interface ObjectWithDecimalProperties.ObjectWithDecimalProperties1Boxed
sealed interface for validated payloads
record ObjectWithDecimalProperties.ObjectWithDecimalProperties1BoxedMap
boxed class to store validated Map payloads
static class ObjectWithDecimalProperties.ObjectWithDecimalProperties1
schema class
static class ObjectWithDecimalProperties.ObjectWithDecimalPropertiesMapBuilder
builder for Map payloads
static class ObjectWithDecimalProperties.ObjectWithDecimalPropertiesMap
output class for Map payloads
sealed interface ObjectWithDecimalProperties.WidthBoxed
sealed interface for validated payloads
record ObjectWithDecimalProperties.WidthBoxedString
boxed class to store validated String payloads
static class ObjectWithDecimalProperties.Width
schema class

ObjectWithDecimalProperties1Boxed

public sealed interface ObjectWithDecimalProperties1Boxed
permits
ObjectWithDecimalProperties1BoxedMap

sealed interface that stores validated payloads using boxed classes

ObjectWithDecimalProperties1BoxedMap

public record ObjectWithDecimalProperties1BoxedMap
implements ObjectWithDecimalProperties1Boxed

record that stores validated Map payloads, sealed permits implementation

Constructor Summary

Constructor and Description
ObjectWithDecimalProperties1BoxedMap(ObjectWithDecimalPropertiesMap data)
Creates an instance, private visibility

Method Summary

Modifier and Type Method and Description
ObjectWithDecimalPropertiesMap data()
validated payload
@Nullable Object getData()
validated payload

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 org.openapijsonschematools.client.components.schemas.ObjectWithDecimalProperties;

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

static final SchemaConfiguration configuration = new SchemaConfiguration(new JsonSchemaKeywordFlags.Builder().build());

// 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)
ObjectWithDecimalProperties1BoxedMap validateAndBox(Map<?, ?> arg, SchemaConfiguration configuration)
ObjectWithDecimalProperties1Boxed validateAndBox(@Nullable Object 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

WidthBoxed

public sealed interface WidthBoxed
permits
WidthBoxedString

sealed interface that stores validated payloads using boxed classes

WidthBoxedString

public record WidthBoxedString
implements WidthBoxed

record that stores validated String payloads, sealed permits implementation

Constructor Summary

Constructor and Description
WidthBoxedString(String data)
Creates an instance, private visibility

Method Summary

Modifier and Type Method and Description
String data()
validated payload
@Nullable Object getData()
validated payload

Width

public static class Width
extends DecimalJsonSchema.DecimalJsonSchema1

A schema class that validates payloads

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

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