Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5da4598
Enables the list/map validator validate methods
spacether Dec 24, 2023
990b9d1
Updates schema docs, fixes two autogen java tests
spacether Dec 24, 2023
7bb8c69
Adds throwing info in getNewInstance, adds general validate method in…
spacether Dec 24, 2023
807644c
Fixes array and map type schema tests
spacether Dec 24, 2023
6afd299
Updates UuidJsonSchema
spacether Dec 24, 2023
6d5503a
Updates StringJsonSchema
spacether Dec 24, 2023
72146cd
Updates DateJsonSchema
spacether Dec 24, 2023
4ea0115
Updates DateTimeJsonSchema
spacether Dec 24, 2023
bb405bb
Updates DecimalJsonSchema
spacether Dec 24, 2023
ded759c
Updates ListJsonSchema
spacether Dec 24, 2023
010d38a
Updates MapJsonSchema
spacether Dec 24, 2023
a798fe5
Updates DoubleJsonSchema
spacether Dec 24, 2023
3ff4cdc
Updates FloatJsonSchema
spacether Dec 24, 2023
4c5cd83
Updates Int32JsonSchema
spacether Dec 24, 2023
aece303
Fixes Int64JsonSchema
spacether Dec 24, 2023
05dd0fa
Updates IntJsonSchema
spacether Dec 24, 2023
e7e96a5
Adds missing validate method to anytype schemas
spacether Dec 24, 2023
b62581a
Updates NullJsonSchema
spacether Dec 24, 2023
cc6f163
Updates NumberJsonSchema
spacether Dec 24, 2023
657333c
Updates BooleanJsonSchema
spacether Dec 24, 2023
a3d7112
Fixes java tests
spacether Dec 24, 2023
1e60ef1
Tests updated to use new general schema validate method
spacether Dec 24, 2023
e0506e3
Removes supress warning unchecked
spacether Dec 24, 2023
c7154cd
Docs updated
spacether Dec 24, 2023
5ac8eaa
Samples updated
spacether Dec 24, 2023
311b7b6
Samples and docs updated
spacether Dec 24, 2023
7dc2e86
Fixes type working for EmtyMap
spacether Dec 24, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updates IntJsonSchema
  • Loading branch information
spacether committed Dec 24, 2023
commit 05dd0fa60d4ec4b601fa7eb1e3b2456b69c421cd
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@

import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags;
import org.openapijsonschematools.client.exceptions.InvalidTypeException;
import org.openapijsonschematools.client.schemas.validation.FormatValidator;
import org.openapijsonschematools.client.schemas.validation.JsonSchema;
import org.openapijsonschematools.client.schemas.validation.JsonSchemaInfo;
import org.openapijsonschematools.client.configurations.SchemaConfiguration;
import org.openapijsonschematools.client.schemas.validation.KeywordEntry;
import org.openapijsonschematools.client.schemas.validation.PathToSchemasMap;
import org.openapijsonschematools.client.schemas.validation.NumberSchemaValidator;
import org.openapijsonschematools.client.schemas.validation.TypeValidator;
import org.openapijsonschematools.client.exceptions.ValidationException;
import org.openapijsonschematools.client.schemas.validation.ValidationMetadata;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.Map;

public class IntJsonSchema extends JsonSchema implements NumberSchemaValidator {
private static @Nullable IntJsonSchema instance = null;
Expand All @@ -44,11 +39,6 @@ public static IntJsonSchema getInstance() {
return instance;
}

@Override
public Number getNewInstance(Number arg, List<Object> pathToItem, PathToSchemasMap pathToSchemas) {
return arg;
}

@Override
public Number validate(Number arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException {
Set<List<Object>> pathSet = new HashSet<>();
Expand Down Expand Up @@ -83,4 +73,12 @@ public double validate(double arg, SchemaConfiguration configuration) throws Val
}
throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be instantiated by this schema");
}

@Override
public @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws InvalidTypeException, ValidationException {
if (arg instanceof Number) {
return validate((Number) arg, configuration);
}
throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be validated by this schema");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@ package {{{packageName}}}.schemas;

import {{{packageName}}}.configurations.JsonSchemaKeywordFlags;
import {{{packageName}}}.exceptions.InvalidTypeException;
import {{{packageName}}}.schemas.validation.FormatValidator;
import {{{packageName}}}.schemas.validation.JsonSchema;
import {{{packageName}}}.schemas.validation.JsonSchemaInfo;
import {{{packageName}}}.configurations.SchemaConfiguration;
import {{{packageName}}}.schemas.validation.KeywordEntry;
import {{{packageName}}}.schemas.validation.PathToSchemasMap;
import {{{packageName}}}.schemas.validation.NumberSchemaValidator;
import {{{packageName}}}.schemas.validation.TypeValidator;
import {{{packageName}}}.exceptions.ValidationException;
import {{{packageName}}}.schemas.validation.ValidationMetadata;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.Map;

public class IntJsonSchema extends JsonSchema implements NumberSchemaValidator {
private static @Nullable IntJsonSchema instance = null;
Expand All @@ -44,11 +39,6 @@ public class IntJsonSchema extends JsonSchema implements NumberSchemaValidator {
return instance;
}

@Override
public Number getNewInstance(Number arg, List<Object> pathToItem, PathToSchemasMap pathToSchemas) {
return arg;
}

@Override
public Number validate(Number arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException {
Set<List<Object>> pathSet = new HashSet<>();
Expand Down Expand Up @@ -83,4 +73,12 @@ public class IntJsonSchema extends JsonSchema implements NumberSchemaValidator {
}
throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be instantiated by this schema");
}

@Override
public @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws InvalidTypeException, ValidationException {
if (arg instanceof Number) {
return validate((Number) arg, configuration);
}
throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be validated by this schema");
}
}