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

Latest commit

 

History

History
128 lines (103 loc) · 5.51 KB

File metadata and controls

128 lines (103 loc) · 5.51 KB

FromSchema

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

A class that contains necessary nested

  • schema classes (which validate payloads), extends JsonSchema
  • classes to store validated map payloads, extends FrozenMap
  • classes to build inputs for map payloads

Nested Class Summary

Modifier and Type Class and Description
static class FromSchema.FromSchema1
schema class
static class FromSchema.FromSchemaMapBuilder
builder for Map payloads
static class FromSchema.FromSchemaMap
output class for Map payloads
static class FromSchema.Id
schema class
static class FromSchema.Data
schema class

FromSchema1

public static class FromSchema1
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 java.util.Arrays;
import java.util.List;
import java.util.AbstractMap;

static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());

// Map validation
FromSchema.FromSchemaMap validatedPayload =
    FromSchema.FromSchema1.validate(
    new FromSchema.FromSchemaMapBuilder()
        .data("a")

        .id(1L)

    .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("data", Data.class)),
    new PropertyEntry("id", Id.class))
)

Method Summary

Modifier and Type Method and Description
FromSchemaMap validate(Map<?, ?> arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

FromSchemaMapBuilder

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

A class that builds the Map input type

Constructor Summary

Constructor and Description
FromSchemaMapBuilder()
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
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)

FromSchemaMap

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

A class to store validated Map payloads

Method Summary

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

Id

public static class Id
extends IntJsonSchema

A schema class that validates payloads

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

Data

public static class Data
extends StringJsonSchema

A schema class that validates payloads

Methods Inherited from class org.openapijsonschematools.client.schemas.StringJsonSchema
validate

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