Skip to content

Latest commit

 

History

History
84 lines (67 loc) · 3.14 KB

File metadata and controls

84 lines (67 loc) · 3.14 KB

Bar

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

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

Nested Class Summary

Modifier and Type Class and Description
sealed interface Bar.Bar1Boxed
sealed interface for validated payloads
record Bar.Bar1BoxedString
boxed class to store validated String payloads
static class Bar.Bar1
schema class

Bar1Boxed

public sealed interface Bar1Boxed
permits
Bar1BoxedString

sealed interface that stores validated payloads using boxed classes

Bar1BoxedString

public record Bar1BoxedString
implements Bar1Boxed

record that stores validated String payloads, sealed permits implementation

Constructor Summary

Constructor and Description
Bar1BoxedString(String data)
Creates an instance, private visibility

Method Summary

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

Bar1

public static class Bar1
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.Bar;

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

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

// String validation
String validatedPayload = Bar.Bar1.validate(
    "a",
    configuration
);

Field Summary

Modifier and Type Field and Description
Set<Class<?>> type = Set.of(
    String.class
)
@Nullable Object defaultValue = "bar"

Method Summary

Modifier and Type Method and Description
String validate(String arg, SchemaConfiguration configuration)
Bar1BoxedString validateAndBox(String arg, SchemaConfiguration configuration)
Bar1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration)
@Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration)

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