org.openapijsonschematools.client.components.schemas.FromSchema.java
public class FromSchema
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
Modifier and Type | Class and Description |
---|---|
sealed interface | FromSchema.FromSchema1Boxed sealed interface for validated payloads |
record | FromSchema.FromSchema1BoxedMap boxed class to store validated Map payloads |
static class | FromSchema.FromSchema1 schema class |
static class | FromSchema.FromSchemaMapBuilder builder for Map payloads |
static class | FromSchema.FromSchemaMap output class for Map payloads |
sealed interface | FromSchema.IdBoxed sealed interface for validated payloads |
record | FromSchema.IdBoxedNumber boxed class to store validated Number payloads |
static class | FromSchema.Id schema class |
sealed interface | FromSchema.DataBoxed sealed interface for validated payloads |
record | FromSchema.DataBoxedString boxed class to store validated String payloads |
static class | FromSchema.Data schema class |
public sealed interface FromSchema1Boxed
permits
FromSchema1BoxedMap
sealed interface that stores validated payloads using boxed classes
public record FromSchema1BoxedMap
implements FromSchema1Boxed
record that stores validated Map payloads, sealed permits implementation
Constructor and Description |
---|
FromSchema1BoxedMap(FromSchemaMap data) Creates an instance, private visibility |
Modifier and Type | Method and Description |
---|---|
FromSchemaMap | data() validated payload |
@Nullable Object | getData() validated payload |
public static class FromSchema1
extends JsonSchema
A schema class that validates payloads
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.FromSchema;
import java.util.Arrays;
import java.util.List;
import java.util.AbstractMap;
static final SchemaConfiguration configuration = new SchemaConfiguration(new JsonSchemaKeywordFlags.Builder().build());
// Map validation
FromSchema.FromSchemaMap validatedPayload =
FromSchema.FromSchema1.validate(
new FromSchema.FromSchemaMapBuilder()
.data("a")
.id(1)
.build(),
configuration
);
Modifier and Type | Field and Description |
---|---|
Set<Class<?>> | type = Set.of(Map.class) |
Map<String, Class<? extends JsonSchema>> | properties = Map.ofEntries( new PropertyEntry("data", Data.class)), new PropertyEntry("id", Id.class)) ) |
Modifier and Type | Method and Description |
---|---|
FromSchemaMap | validate(Map<?, ?> arg, SchemaConfiguration configuration) |
FromSchema1BoxedMap | validateAndBox(Map<?, ?> arg, SchemaConfiguration configuration) |
FromSchema1Boxed | validateAndBox(@Nullable Object arg, SchemaConfiguration configuration) |
@Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) |
public class FromSchemaMapBuilder
builder for Map<String, @Nullable Object>
A class that builds the Map input type
Constructor and Description |
---|
FromSchemaMapBuilder() Creates a builder that contains an empty map |
Modifier and Type | Method and Description |
---|---|
Map<String, @Nullable Object> | build() Returns map input that should be used with Schema.validate |
FromSchemaMapBuilder | data(String value) |
FromSchemaMapBuilder | id(int value) |
FromSchemaMapBuilder | id(float value) |
FromSchemaMapBuilder | id(long value) |
FromSchemaMapBuilder | id(double value) |
FromSchemaMapBuilder | additionalProperty(String key, Void value) |
FromSchemaMapBuilder | additionalProperty(String key, boolean value) |
FromSchemaMapBuilder | additionalProperty(String key, String value) |
FromSchemaMapBuilder | additionalProperty(String key, int value) |
FromSchemaMapBuilder | additionalProperty(String key, float value) |
FromSchemaMapBuilder | additionalProperty(String key, long value) |
FromSchemaMapBuilder | additionalProperty(String key, double value) |
FromSchemaMapBuilder | additionalProperty(String key, List<?> value) |
FromSchemaMapBuilder | additionalProperty(String key, Map<String, ?> value) |
public static class FromSchemaMap
extends FrozenMap<String, @Nullable Object>
A class to store validated Map payloads
Modifier and Type | Method and Description |
---|---|
static FromSchemaMap | of(Map<String, ? extends @Nullable Object> arg, SchemaConfiguration configuration) |
String | data() [optional] |
Number | id() [optional] |
@Nullable Object | getAdditionalProperty(String name) provides type safety for additional properties |
public sealed interface IdBoxed
permits
IdBoxedNumber
sealed interface that stores validated payloads using boxed classes
public record IdBoxedNumber
implements IdBoxed
record that stores validated Number payloads, sealed permits implementation
Constructor and Description |
---|
IdBoxedNumber(Number data) Creates an instance, private visibility |
Modifier and Type | Method and Description |
---|---|
Number | data() validated payload |
@Nullable Object | getData() validated payload |
public static class Id
extends IntJsonSchema.IntJsonSchema1
A schema class that validates payloads
Methods Inherited from class org.openapijsonschematools.client.schemas.IntJsonSchema.IntJsonSchema1 |
---|
validate |
validateAndBox |
public sealed interface DataBoxed
permits
DataBoxedString
sealed interface that stores validated payloads using boxed classes
public record DataBoxedString
implements DataBoxed
record that stores validated String payloads, sealed permits implementation
Constructor and Description |
---|
DataBoxedString(String data) Creates an instance, private visibility |
Modifier and Type | Method and Description |
---|---|
String | data() validated payload |
@Nullable Object | getData() validated payload |
public static class Data
extends StringJsonSchema.StringJsonSchema1
A schema class that validates payloads
Methods Inherited from class org.openapijsonschematools.client.schemas.StringJsonSchema.StringJsonSchema1 |
---|
validate |
validateAndBox |