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

Latest commit

 

History

History
188 lines (150 loc) · 7.8 KB

File metadata and controls

188 lines (150 loc) · 7.8 KB

Banana

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

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 Banana.Banana1Boxed
sealed interface for validated payloads
record Banana.Banana1BoxedMap
boxed class to store validated Map payloads
static class Banana.Banana1
schema class
static class Banana.BananaMapBuilder
builder for Map payloads
static class Banana.BananaMap
output class for Map payloads
sealed interface Banana.LengthCmBoxed
sealed interface for validated payloads
record Banana.LengthCmBoxedNumber
boxed class to store validated Number payloads
static class Banana.LengthCm
schema class

Banana1Boxed

public sealed interface Banana1Boxed
permits
Banana1BoxedMap

sealed interface that stores validated payloads using boxed classes

Banana1BoxedMap

public record Banana1BoxedMap
implements Banana1Boxed

record that stores validated Map payloads, sealed permits implementation

Constructor Summary

Constructor and Description
Banana1BoxedMap(BananaMap data)
Creates an instance, private visibility

Method Summary

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

Banana1

public static class Banana1
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.Banana;

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

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

// Map validation
Banana.BananaMap validatedPayload =
    Banana.Banana1.validate(
    new Banana.BananaMapBuilder()
        .lengthCm(1)

    .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("lengthCm", LengthCm.class))
)
Set required = Set.of(
    "lengthCm"
)

Method Summary

Modifier and Type Method and Description
BananaMap validate(Map<?, ?> arg, SchemaConfiguration configuration)
Banana1BoxedMap validateAndBox(Map<?, ?> arg, SchemaConfiguration configuration)
Banana1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

BananaMap0Builder

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

A class that builds the Map input type

Constructor Summary

Constructor and Description
BananaMap0Builder(Map<String, @Nullable Object> instance)
Creates a builder that contains the passed instance

Method Summary

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

BananaMapBuilder

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

A class that builds the Map input type

Constructor Summary

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

Method Summary

Modifier and Type Method and Description
BananaMap0Builder lengthCm(int value)
BananaMap0Builder lengthCm(float value)
BananaMap0Builder lengthCm(long value)
BananaMap0Builder lengthCm(double value)

BananaMap

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

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static BananaMap of(Map<String, ? extends @Nullable Object> arg, SchemaConfiguration configuration)
Number lengthCm()
@Nullable Object getAdditionalProperty(String name)
provides type safety for additional properties

LengthCmBoxed

public sealed interface LengthCmBoxed
permits
LengthCmBoxedNumber

sealed interface that stores validated payloads using boxed classes

LengthCmBoxedNumber

public record LengthCmBoxedNumber
implements LengthCmBoxed

record that stores validated Number payloads, sealed permits implementation

Constructor Summary

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

Method Summary

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

LengthCm

public static class LengthCm
extends NumberJsonSchema.NumberJsonSchema1

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.NumberJsonSchema.NumberJsonSchema1
validate
validateAndBox

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