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

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

5deb73a · Dec 6, 2023

History

History
105 lines (84 loc) · 4.39 KB

File metadata and controls

105 lines (84 loc) · 4.39 KB

Money

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

A class that contains necessary nested schema classes, and classes to store validated list and map payloads

Nested Class Summary

Modifier and Type Class and Description
static class Money.Money1
schema class
static class Money.MoneyMap
output class for Map payloads
static class Money.Amount
schema class
static class Money.AdditionalProperties
schema class

Money1

public static class Money1
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.MapMaker;
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
Money.MoneyMap validatedPayload =
    Money.Money1.validate(
    MapMaker.makeMap(
        new AbstractMap.SimpleEntry<>(
            "amount",
            "3.14"
        ),
        new AbstractMap.SimpleEntry<>(
            "currency",
            "eur"
        )
    ),
    configuration
);

Field Summary

Modifier and Type Field and Description
static LinkedHashMap<String, KeywordValidator> keywordToValidator
new LinkedHashMap<>(Map.ofEntries(
    new KeywordEntry("type", new TypeValidator(Set.of(FrozenMap.class))),
    new KeywordEntry("properties", new PropertiesValidator(Map.ofEntries(
        new PropertyEntry("amount", Amount.class)),
        new PropertyEntry("currency", Currency.Currency1.class)
    ))),
    new KeywordEntry("required", new RequiredValidator(Set.of(
        "amount",
        "currency"
    ))),
    new KeywordEntry("additionalProperties", new AdditionalPropertiesValidator(AdditionalProperties.class))
));

Method Summary

Modifier and Type Method and Description
static MoneyMap validate(Map<String, Object> arg, SchemaConfiguration configuration)

MoneyMap

public static class MoneyMap
extends FrozenMap<String, Object>

A class to store validated Map payloads

Method Summary

Modifier and Type Method and Description
static MoneyMap of(Map<String, Object> arg, SchemaConfiguration configuration)
String amount()
value must be int or float numeric
String currency()

Input Map Keys

type: Map<String, Object>
Key Type Description Notes
amount String value must be int or float numeric
currency String

Amount

public static class Amount
extends DecimalJsonSchema

A schema class that validates payloads

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

AdditionalProperties

public static class AdditionalProperties
extends NotAnyTypeJsonSchema

A schema class that validates payloads

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

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