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

Latest commit

 

History

History
160 lines (126 loc) · 6.08 KB

File metadata and controls

160 lines (126 loc) · 6.08 KB

Items

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

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 list payloads, extends FrozenList
  • classes to build inputs for list payloads

Nested Class Summary

Modifier and Type Class and Description
sealed interface Items.Items1Boxed
sealed interface for validated payloads
record Items.Items1BoxedList
boxed class to store validated List payloads
static class Items.Items1
schema class
static class Items.ItemsListBuilder
builder for List payloads
static class Items.ItemsList
output class for List payloads
sealed interface Items.Items2Boxed
sealed interface for validated payloads
record Items.Items2BoxedMap
boxed class to store validated Map payloads
static class Items.Items2
schema class

Items1Boxed

public sealed interface Items1Boxed
permits
Items1BoxedList

sealed interface that stores validated payloads using boxed classes

Items1BoxedList

public record Items1BoxedList
implements Items1Boxed

record that stores validated List payloads, sealed permits implementation

Constructor Summary

Constructor and Description
Items1BoxedList(ItemsList data)
Creates an instance, private visibility

Method Summary

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

Items1

public static class Items1
extends JsonSchema

A schema class that validates payloads

Description

component's name collides with the inner schema name

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.Items;

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

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

// List validation
Items.ItemsList validatedPayload =
    Items.Items1.validate(
    new Items.ItemsListBuilder()
    .build(),
    configuration
);

Field Summary

Modifier and Type Field and Description
Set<Class<?>> type = Set.of(List.class)
Class<? extends JsonSchema> items = Items2.class

Method Summary

Modifier and Type Method and Description
ItemsList validate(List<?> arg, SchemaConfiguration configuration)
Items1BoxedList validateAndBox(List<?> arg, SchemaConfiguration configuration)
Items1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

ItemsListBuilder

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

A class that builds the List input type

Constructor Summary

Constructor and Description
ItemsListBuilder()
Creates an empty list
ItemsListBuilder(List<Map<String, @Nullable Object>> items)
Stores the items in a list

Method Summary

Modifier and Type Method and Description
ItemsListBuilder add(Map<String, @Nullable Object> item)
List<Map<String, @Nullable Object>> build()
Returns list input that should be used with Schema.validate

ItemsList

public class ItemsList
extends FrozenList<FrozenMap<?>>

A class to store validated List payloads

Method Summary

Modifier and Type Method and Description
static ItemsList of(List<Map<String, ? extends @Nullable Object>> arg, SchemaConfiguration configuration)

Items2Boxed

public sealed interface Items2Boxed
permits
Items2BoxedMap

sealed interface that stores validated payloads using boxed classes

Items2BoxedMap

public record Items2BoxedMap
implements Items2Boxed

record that stores validated Map payloads, sealed permits implementation

Constructor Summary

Constructor and Description
Items2BoxedMap(FrozenMap<@Nullable Object> data)
Creates an instance, private visibility

Method Summary

Modifier and Type Method and Description
FrozenMap<@Nullable Object> data()
validated payload
@Nullable Object getData()
validated payload

Items2

public static class Items2
extends MapJsonSchema.MapJsonSchema1

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.MapJsonSchema.MapJsonSchema1
validate
validateAndBox

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