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

Commit 0d15286

Browse files
committed
Adds anytype detection
1 parent 955b028 commit 0d15286

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayHoldingAnyType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.LinkedHashSet;
66
import java.util.Set;
77
import java.util.List;
8+
import org.openapijsonschematools.schemas.AnyTypeJsonSchema;
89
import org.openapijsonschematools.schemas.FrozenList;
910

1011
public class ArrayHoldingAnyType {

samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/User.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.AbstractMap;
88
import java.util.LinkedHashMap;
99
import java.util.Map;
10+
import org.openapijsonschematools.schemas.AnyTypeJsonSchema;
1011
import org.openapijsonschematools.schemas.FrozenMap;
1112
import org.openapijsonschematools.schemas.Int32JsonSchema;
1213
import org.openapijsonschematools.schemas.Int64JsonSchema;

src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ public Set<String> getImports(String sourceJsonPath, CodegenSchema schema, Featu
12451245
imports.add("import "+packageName + ".schemas.AnyTypeJsonSchema;");
12461246
} else if (schema.isBooleanSchemaFalse) {
12471247
imports.add("import "+packageName + ".schemas.NotAnyTypeJsonSchema;");
1248+
} else if (schema.isSimpleAnyType()) {
1249+
imports.add("import "+packageName + ".schemas.AnyTypeJsonSchema;");
12481250
}
12491251
}
12501252
return imports;

src/main/java/org/openapijsonschematools/codegen/generators/openapimodels/CodegenSchema.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ public boolean isSimpleArray() {
241241
return true;
242242
}
243243

244+
public boolean isSimpleAnyType() {
245+
if (types != null) {
246+
return false;
247+
}
248+
if (allOf != null || anyOf != null || oneOf != null || not != null || if_ != null || then != null || else_ != null || enumInfo != null || constInfo != null || properties != null || requiredProperties != null || hasDiscriminatorWithNonEmptyMapping() != false || additionalProperties != null || dependentRequired != null || dependentSchemas != null || propertyNames != null || maxProperties != null || minProperties != null || patternProperties != null || unevaluatedProperties != null || items != null || uniqueItems != null || maxItems != null || minItems != null || contains != null || maxContains != null || minContains != null || prefixItems != null || unevaluatedItems != null || format != null || maxLength != null || minLength != null || maximum != null || minimum != null || multipleOf != null || patternInfo != null || refInfo != null) {
249+
return false;
250+
}
251+
return true;
252+
}
253+
244254
public CodegenSchema typeSchema() {
245255
CodegenSchema schema = new CodegenSchema();
246256
schema.refInfo = refInfo;

0 commit comments

Comments
 (0)