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

Latest commit

 

History

History
162 lines (128 loc) · 6.68 KB

File metadata and controls

162 lines (128 loc) · 6.68 KB

Address

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

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 Address.Address1Boxed
sealed interface for validated payloads
record Address.Address1BoxedMap
boxed class to store validated Map payloads
static class Address.Address1
schema class
static class Address.AddressMapBuilder
builder for Map payloads
static class Address.AddressMap
output class for Map payloads
sealed interface Address.AdditionalPropertiesBoxed
sealed interface for validated payloads
record Address.AdditionalPropertiesBoxedNumber
boxed class to store validated Number payloads
static class Address.AdditionalProperties
schema class

Address1Boxed

public sealed interface Address1Boxed
permits
Address1BoxedMap

sealed interface that stores validated payloads using boxed classes

Address1BoxedMap

public record Address1BoxedMap
implements Address1Boxed

record that stores validated Map payloads, sealed permits implementation

Constructor Summary

Constructor and Description
Address1BoxedMap(AddressMap data)
Creates an instance, private visibility

Method Summary

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

Address1

public static class Address1
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.Address;

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

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

// Map validation
Address.AddressMap validatedPayload =
    Address.Address1.validate(
    new Address.AddressMapBuilder()
        .additionalProperty("someAdditionalProperty", 1)

    .build(),
    configuration
);

Field Summary

Modifier and Type Field and Description
Set<Class<?>> type = Set.of(Map.class)
Class<? extends JsonSchema> additionalProperties = AdditionalProperties.class

Method Summary

Modifier and Type Method and Description
AddressMap validate(Map<?, ?> arg, SchemaConfiguration configuration)
Address1BoxedMap validateAndBox(Map<?, ?> arg, SchemaConfiguration configuration)
Address1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

AddressMapBuilder

public class AddressMapBuilder
builder for Map<String, Number>

A class that builds the Map input type

Constructor Summary

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

Method Summary

Modifier and Type Method and Description
Map<String, Number> build()
Returns map input that should be used with Schema.validate
AddressMapBuilder additionalProperty(String key, int value)
AddressMapBuilder additionalProperty(String key, float value)
AddressMapBuilder additionalProperty(String key, long value)
AddressMapBuilder additionalProperty(String key, double value)

AddressMap

public static class AddressMap
extends FrozenMap<String, Number>

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static AddressMap of(Map<String, Number> arg, SchemaConfiguration configuration)
Number getAdditionalProperty(String name)
provides type safety for additional properties

AdditionalPropertiesBoxed

public sealed interface AdditionalPropertiesBoxed
permits
AdditionalPropertiesBoxedNumber

sealed interface that stores validated payloads using boxed classes

AdditionalPropertiesBoxedNumber

public record AdditionalPropertiesBoxedNumber
implements AdditionalPropertiesBoxed

record that stores validated Number payloads, sealed permits implementation

Constructor Summary

Constructor and Description
AdditionalPropertiesBoxedNumber(Number data)
Creates an instance, private visibility

Method Summary

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

AdditionalProperties

public static class AdditionalProperties
extends IntJsonSchema.IntJsonSchema1

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.IntJsonSchema.IntJsonSchema1
validate
validateAndBox

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