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
78 commits
Select commit Hold shift + click to select a range
d11490f
Adds kotlin petstore sample
spacether May 2, 2024
8f0c9bc
Changes status to experimental
spacether May 2, 2024
028c529
Updates 2 configuration classes
spacether May 6, 2024
8efbe19
Converts all exceptions to kotlin
spacether May 6, 2024
fd1b0dd
Converts KeywordValidator and supporting classes to Kotlin
spacether May 6, 2024
b930d58
Updates kotlin jsonschema templates and supporting classes
spacether May 6, 2024
c5513c4
Reverts java templates
spacether May 6, 2024
63724fa
Updates AdditionalPropertiesValidator
spacether May 6, 2024
98f6257
Updates UnsetAnyTypeJsonSchema
spacether May 7, 2024
60a42f3
Move improvemnts for kotlin code of json schema and unset anytype schema
spacether May 7, 2024
7ca254d
Updates companion object for unset any type schema
spacether May 7, 2024
3d50a91
More improvements to UnsetAnyTypeJsonSchema
spacether May 7, 2024
c912298
Fixes more types in UnsetAnyTypeJsonSchema1Boxed
spacether May 7, 2024
8e2371f
Updates FrozenList and FrozenMap
spacether May 7, 2024
7a4b722
Updates FrozenList/Map
spacether May 7, 2024
2a472c3
Reverts java template changes
spacether May 7, 2024
585f865
Fixes all of the type validator interfaces
spacether May 7, 2024
fb9dc33
Updates type validator
spacether May 7, 2024
8f3e822
Updates FormatValidator
spacether May 7, 2024
bd8bed4
Updates ItemsValidator
spacether May 8, 2024
05a77b9
Updates RequiredValidator
spacether May 8, 2024
a6a1f1b
Updates ExclusiveMaximumValidator
spacether May 8, 2024
8d2f0b2
Updates ExclusiveMinimumValidator
spacether May 8, 2024
447f1b0
Updates max and min items validators
spacether May 8, 2024
4f1703a
Updates Max and Min length validators
spacether May 8, 2024
11bd256
Updates max and min properties validator
spacether May 8, 2024
6051806
Updates max and min validator
spacether May 8, 2024
7d0d2f2
Fixes some intelij warnings in the jsonschema class
spacether May 8, 2024
d0ac93c
Updates AllOfValidator
spacether May 8, 2024
646db81
Updates anyof and oneof validators
spacether May 8, 2024
f9addbf
Updates not and unique items validators
spacether May 8, 2024
006774b
Updates enum + pattern validators
spacether May 8, 2024
1f7652b
Updates const and contains validator
spacether May 8, 2024
e7b057a
Updates max and min contains validators
spacether May 8, 2024
cd1ac1d
Updates DependentRequiredValidator + PropertyNamesValidator
spacether May 8, 2024
20f5613
Updates DependentSchemasValidator + PatternPropertiesValidator
spacether May 8, 2024
ae18ab2
Updates IfValidator + PrefixItemsValidator
spacether May 8, 2024
643da09
Updates ElseValidator + ThenValidator
spacether May 8, 2024
e21dd34
Updates UnevaluatedItemsValidator + UnevaluatedPropertiesValidator
spacether May 8, 2024
5521ebe
Updates AnyTypeJsonSchema
spacether May 9, 2024
f887577
Updates NotAnyTypeJsonSchema
spacether May 9, 2024
4efe364
Updates BooleanJsonSchema
spacether May 9, 2024
798b77a
Adds NullJsonSchema
spacether May 9, 2024
036ecc9
Updates StringJsonSchema
spacether May 9, 2024
2c451ae
Updates ListJsonSchema
spacether May 9, 2024
ad7cd07
Updates MapJsonSchema
spacether May 9, 2024
3106125
Updates NumberJsonSchema
spacether May 9, 2024
e05b170
Updates DateJsonSchema
spacether May 9, 2024
5eeae6a
Updates DateTimeJsonSchema
spacether May 9, 2024
b1f7250
Updates DecimalJsonSchema
spacether May 9, 2024
bd787ab
Adds DoubleJsonSchema
spacether May 9, 2024
c4abd5e
Updates FloatJsonSchema
spacether May 9, 2024
2ef5e38
Updates GenericBuilder
spacether May 9, 2024
f331bf8
Uses intsAllowedForFloatDoubleFormats in Float/Double schemas
spacether May 9, 2024
3be6a1e
Updates Int32JsonSchema
spacether May 9, 2024
b71e163
Updates Int64JsonSchema
spacether May 9, 2024
9313454
Updates IntJsonSchema
spacether May 9, 2024
4bc351b
Updates SetMaker and UnsetAddPropsSetter
spacether May 9, 2024
bea0ee4
Samples and docs regen
spacether May 17, 2024
458928f
Kotlin 310 sample gen
spacether May 17, 2024
d25216e
Updates dependentSchemas
spacether May 17, 2024
22cd355
Updates dependentRequired
spacether May 17, 2024
1e24856
Updates patternProperties
spacether May 17, 2024
369a9af
Includes patternProperties in calculation of mapValueSchema
spacether May 17, 2024
79bf237
Omits getKnownKeys method when additionalProperties is turned off
spacether May 17, 2024
2ee8809
Fixes value checking of lists of any type in map output getters
spacether May 18, 2024
fbc196b
Fixes output type issues for property getters
spacether May 18, 2024
10e154b
Adds 310 kotlin test to ci
spacether May 19, 2024
651d229
Samples regen
spacether May 19, 2024
731a238
Adjusts gradlew command
spacether May 19, 2024
2fa9be6
Update build file to increase the max jvm memory limit when compiling
spacether May 20, 2024
ec334a6
Removes nodaemon arg on gradle test invocation
spacether May 20, 2024
d56bb22
Adds info logging to 310 gradle test
spacether May 20, 2024
f5ff4d8
Adds info logging
spacether May 20, 2024
b832b95
Increases memory to 512 mB
spacether May 20, 2024
dfc5f47
Increases memory to 1 g
spacether May 20, 2024
e4a788d
Updates template default to 1g
spacether May 20, 2024
9ab973e
Readme updated
spacether May 20, 2024
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 Int32JsonSchema
  • Loading branch information
spacether committed May 9, 2024
commit 3be6a1e4f730048e3cc723cac33b3e9a2f7dd0fb
Original file line number Diff line number Diff line change
@@ -1,98 +1,93 @@
package org.openapijsonschematools.client.schemas;
package org.openapijsonschematools.client.schemas

import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags;
import org.openapijsonschematools.client.exceptions.ValidationException;
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.PathToSchemasMap;
import org.openapijsonschematools.client.schemas.validation.NumberSchemaValidator;
import org.openapijsonschematools.client.schemas.validation.ValidationMetadata;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags
import org.openapijsonschematools.client.configurations.SchemaConfiguration
import org.openapijsonschematools.client.exceptions.ValidationException
import org.openapijsonschematools.client.schemas.validation.JsonSchema
import org.openapijsonschematools.client.schemas.validation.JsonSchemaInfo
import org.openapijsonschematools.client.schemas.validation.NumberSchemaValidator
import org.openapijsonschematools.client.schemas.validation.PathToSchemasMap
import org.openapijsonschematools.client.schemas.validation.ValidationMetadata

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

public class Int32JsonSchema {
public sealed interface Int32JsonSchema1Boxed permits Int32JsonSchema1BoxedNumber {
@Nullable Object getData();
class Int32JsonSchema {
sealed interface Int32JsonSchema1Boxed {
fun getData(): Any?
}
public record Int32JsonSchema1BoxedNumber(Number data) implements Int32JsonSchema1Boxed {
@Override
public @Nullable Object getData() {
return data;

data class Int32JsonSchema1BoxedNumber(val data: Number) : Int32JsonSchema1Boxed {
override fun getData(): Number {
return data
}
}

public static class Int32JsonSchema1 extends JsonSchema<Int32JsonSchema1Boxed> implements NumberSchemaValidator<Int32JsonSchema1BoxedNumber> {
private static @Nullable Int32JsonSchema1 instance = null;

protected Int32JsonSchema1() {
super(new JsonSchemaInfo()
.type(Set.of(
Integer.class,
Float.class
))
.format("int32")
);
class Int32JsonSchema1 private constructor() : JsonSchema<Int32JsonSchema1Boxed>(
JsonSchemaInfo()
.type(
setOf(
Int::class.java,
Float::class.java
)
)
.format("int32")
), NumberSchemaValidator<Int32JsonSchema1BoxedNumber> {
@Throws(ValidationException::class)
override fun validate(arg: Number, configuration: SchemaConfiguration?): Number {
val pathSet: MutableSet<List<Any>> = HashSet()
val pathToItem = listOf<Any>("args[0")
val castArg: Number = castToAllowedTypes(arg, pathToItem, pathSet)
val usedConfiguration = configuration ?: SchemaConfiguration(JsonSchemaKeywordFlags.Builder().build())
val validationMetadata =
ValidationMetadata(pathToItem, usedConfiguration, PathToSchemasMap(), LinkedHashSet())
val pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet)
return getNewInstance(castArg, validationMetadata.pathToItem, pathToSchemasMap)
}

public static Int32JsonSchema1 getInstance() {
if (instance == null) {
instance = new Int32JsonSchema1();
}
return instance;
@Throws(ValidationException::class)
fun validate(arg: Int, configuration: SchemaConfiguration?): Int {
return validate(arg as Number, configuration) as Int
}

@Override
public Number validate(Number arg, SchemaConfiguration configuration) throws ValidationException {
Set<List<Object>> pathSet = new HashSet<>();
List<Object> pathToItem = List.of("args[0");
Number castArg = castToAllowedTypes(arg, pathToItem, pathSet);
SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(new JsonSchemaKeywordFlags.Builder().build()));
ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, new PathToSchemasMap(), new LinkedHashSet<>());
PathToSchemasMap pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet);
return getNewInstance(castArg, validationMetadata.pathToItem(), pathToSchemasMap);
@Throws(ValidationException::class)
fun validate(arg: Float, configuration: SchemaConfiguration?): Float {
return validate(arg as Number, configuration) as Float
}

public int validate(int arg, SchemaConfiguration configuration) throws ValidationException {
return (int) validate((Number) arg, configuration);
override fun getNewInstance(arg: Any?, pathToItem: List<Any>, pathToSchemas: PathToSchemasMap): Any? {
if (arg is Number) {
return getNewInstance(arg as Number?, pathToItem, pathToSchemas)
}
throw RuntimeException("Invalid input type=$javaClass. It can't be instantiated by this schema")
}

public float validate(float arg, SchemaConfiguration configuration) throws ValidationException {
return (float) validate((Number) arg, configuration);
@Throws(ValidationException::class)
override fun validate(arg: Any?, configuration: SchemaConfiguration?): Number {
if (arg is Number) {
return validate(arg, configuration)
}
throw ValidationException("Invalid input type=$javaClass. It can't be validated by this schema")
}

@Override
public @Nullable Object getNewInstance(@Nullable Object arg, List<Object> pathToItem, PathToSchemasMap pathToSchemas) {
if (arg instanceof Number) {
return getNewInstance((Number) arg, pathToItem, pathToSchemas);
}
throw new RuntimeException("Invalid input type="+getClass(arg)+". It can't be instantiated by this schema");
@Throws(ValidationException::class)
override fun validateAndBox(arg: Number, configuration: SchemaConfiguration?): Int32JsonSchema1BoxedNumber {
return Int32JsonSchema1BoxedNumber(validate(arg, configuration))
}

@Override
public @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException {
if (arg instanceof Number) {
return validate((Number) arg, configuration);
@Throws(ValidationException::class)
override fun validateAndBox(arg: Any?, configuration: SchemaConfiguration?): Int32JsonSchema1Boxed {
if (arg is Number) {
return validateAndBox(arg, configuration)
}
throw new ValidationException("Invalid input type="+getClass(arg)+". It can't be validated by this schema");
throw ValidationException("Invalid input type=$javaClass. It can't be validated by this schema")
}

@Override
public Int32JsonSchema1BoxedNumber validateAndBox(Number arg, SchemaConfiguration configuration) throws ValidationException {
return new Int32JsonSchema1BoxedNumber(validate(arg, configuration));
}
companion object {
@Volatile
private var instance: Int32JsonSchema1? = null

@Override
public Int32JsonSchema1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException {
if (arg instanceof Number castArg) {
return validateAndBox(castArg, configuration);
}
throw new ValidationException("Invalid input type="+getClass(arg)+". It can't be validated by this schema");
fun getInstance() =
instance ?: synchronized(this) {
instance ?: Int32JsonSchema1().also { instance = it }
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,91 +8,86 @@ import {{{packageName}}}.configurations.SchemaConfiguration;
import {{{packageName}}}.schemas.validation.PathToSchemasMap;
import {{{packageName}}}.schemas.validation.NumberSchemaValidator;
import {{{packageName}}}.schemas.validation.ValidationMetadata;
import org.checkerframework.checker.nullness.qual.Nullable;

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

public class Int32JsonSchema {
public sealed interface Int32JsonSchema1Boxed permits Int32JsonSchema1BoxedNumber {
@Nullable Object getData();
class Int32JsonSchema {
sealed interface Int32JsonSchema1Boxed {
fun getData(): Any?
}
public record Int32JsonSchema1BoxedNumber(Number data) implements Int32JsonSchema1Boxed {
@Override
public @Nullable Object getData() {
return data;

data class Int32JsonSchema1BoxedNumber(val data: Number) : Int32JsonSchema1Boxed {
override fun getData(): Number {
return data
}
}

public static class Int32JsonSchema1 extends JsonSchema<Int32JsonSchema1Boxed> implements NumberSchemaValidator<Int32JsonSchema1BoxedNumber> {
private static @Nullable Int32JsonSchema1 instance = null;

protected Int32JsonSchema1() {
super(new JsonSchemaInfo()
.type(Set.of(
Integer.class,
Float.class
))
.format("int32")
);
class Int32JsonSchema1 private constructor() : JsonSchema<Int32JsonSchema1Boxed>(
JsonSchemaInfo()
.type(
setOf(
Int::class.java,
Float::class.java
)
)
.format("int32")
), NumberSchemaValidator<Int32JsonSchema1BoxedNumber> {
@Throws(ValidationException::class)
override fun validate(arg: Number, configuration: SchemaConfiguration?): Number {
val pathSet: MutableSet<List<Any>> = HashSet()
val pathToItem = listOf<Any>("args[0")
val castArg: Number = castToAllowedTypes(arg, pathToItem, pathSet)
val usedConfiguration = configuration ?: SchemaConfiguration(JsonSchemaKeywordFlags.Builder().build())
val validationMetadata =
ValidationMetadata(pathToItem, usedConfiguration, PathToSchemasMap(), LinkedHashSet())
val pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet)
return getNewInstance(castArg, validationMetadata.pathToItem, pathToSchemasMap)
}

public static Int32JsonSchema1 getInstance() {
if (instance == null) {
instance = new Int32JsonSchema1();
}
return instance;
@Throws(ValidationException::class)
fun validate(arg: Int, configuration: SchemaConfiguration?): Int {
return validate(arg as Number, configuration) as Int
}

@Override
public Number validate(Number arg, SchemaConfiguration configuration) throws ValidationException {
Set<List<Object>> pathSet = new HashSet<>();
List<Object> pathToItem = List.of("args[0");
Number castArg = castToAllowedTypes(arg, pathToItem, pathSet);
SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(new JsonSchemaKeywordFlags.Builder().build()));
ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, new PathToSchemasMap(), new LinkedHashSet<>());
PathToSchemasMap pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet);
return getNewInstance(castArg, validationMetadata.pathToItem(), pathToSchemasMap);
@Throws(ValidationException::class)
fun validate(arg: Float, configuration: SchemaConfiguration?): Float {
return validate(arg as Number, configuration) as Float
}

public int validate(int arg, SchemaConfiguration configuration) throws ValidationException {
return (int) validate((Number) arg, configuration);
override fun getNewInstance(arg: Any?, pathToItem: List<Any>, pathToSchemas: PathToSchemasMap): Any? {
if (arg is Number) {
return getNewInstance(arg as Number?, pathToItem, pathToSchemas)
}
throw RuntimeException("Invalid input type=$javaClass. It can't be instantiated by this schema")
}

public float validate(float arg, SchemaConfiguration configuration) throws ValidationException {
return (float) validate((Number) arg, configuration);
@Throws(ValidationException::class)
override fun validate(arg: Any?, configuration: SchemaConfiguration?): Number {
if (arg is Number) {
return validate(arg, configuration)
}
throw ValidationException("Invalid input type=$javaClass. It can't be validated by this schema")
}

@Override
public @Nullable Object getNewInstance(@Nullable Object arg, List<Object> pathToItem, PathToSchemasMap pathToSchemas) {
if (arg instanceof Number) {
return getNewInstance((Number) arg, pathToItem, pathToSchemas);
}
throw new RuntimeException("Invalid input type="+getClass(arg)+". It can't be instantiated by this schema");
@Throws(ValidationException::class)
override fun validateAndBox(arg: Number, configuration: SchemaConfiguration?): Int32JsonSchema1BoxedNumber {
return Int32JsonSchema1BoxedNumber(validate(arg, configuration))
}

@Override
public @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException {
if (arg instanceof Number) {
return validate((Number) arg, configuration);
@Throws(ValidationException::class)
override fun validateAndBox(arg: Any?, configuration: SchemaConfiguration?): Int32JsonSchema1Boxed {
if (arg is Number) {
return validateAndBox(arg, configuration)
}
throw new ValidationException("Invalid input type="+getClass(arg)+". It can't be validated by this schema");
throw ValidationException("Invalid input type=$javaClass. It can't be validated by this schema")
}

@Override
public Int32JsonSchema1BoxedNumber validateAndBox(Number arg, SchemaConfiguration configuration) throws ValidationException {
return new Int32JsonSchema1BoxedNumber(validate(arg, configuration));
}
companion object {
@Volatile
private var instance: Int32JsonSchema1? = null

@Override
public Int32JsonSchema1Boxed validateAndBox(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException {
if (arg instanceof Number castArg) {
return validateAndBox(castArg, configuration);
}
throw new ValidationException("Invalid input type="+getClass(arg)+". It can't be validated by this schema");
fun getInstance() =
instance ?: synchronized(this) {
instance ?: Int32JsonSchema1().also { instance = it }
}
}
}
}