Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ public class DefaultCodegen implements CodegenConfig {
private static final Cache<SanitizeNameOptions, String> sanitizedNameCache;
private static final String xSchemaTestExamplesKey = "x-schema-test-examples";
private static final String xSchemaTestExamplesRefPrefix = "#/components/x-schema-test-examples/";
protected static Schema falseSchema;
protected static Schema trueSchema = new Schema();

static {
DefaultFeatureSet = FeatureSet.newBuilder()
Expand Down Expand Up @@ -151,8 +149,6 @@ public class DefaultCodegen implements CodegenConfig {
.expireAfterAccess(cacheExpiry, TimeUnit.SECONDS)
.ticker(Ticker.systemTicker())
.build();
falseSchema = new Schema();
falseSchema.setNot(new Schema());
}

protected GeneratorMetadata generatorMetadata;
Expand Down Expand Up @@ -304,8 +300,6 @@ apiTemplateFiles are for API outputs only (controllers/handlers).
// A cache to efficiently lookup schema `toModelName()` based on the schema Key
private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();

protected boolean loadDeepObjectIntoItems = true;

// if true then baseTypes will be imported
protected boolean importBaseType = true;

Expand Down Expand Up @@ -3122,11 +3116,6 @@ public CodegenModel fromModel(String name, Schema schema) {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);

CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL);
if (schema.equals(trueSchema)) {
m.setIsBooleanSchemaTrue(true);
} else if (schema.equals(falseSchema)) {
m.setIsBooleanSchemaFalse(true);
}
// unalias schema
schema = unaliasSchema(schema);
if (schema == null) {
Expand Down Expand Up @@ -4012,11 +4001,6 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
}

CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
if (p.equals(trueSchema)) {
property.setIsBooleanSchemaTrue(true);
} else if (p.equals(falseSchema)) {
property.setIsBooleanSchemaFalse(true);
}

// unalias schema
p = unaliasSchema(p);
Expand Down Expand Up @@ -5490,7 +5474,7 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)

codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern());

if (codegenParameter.isQueryParam && codegenParameter.isDeepObject && loadDeepObjectIntoItems) {
if (codegenParameter.isQueryParam && codegenParameter.isDeepObject) {
Schema schema = parameterSchema;
if (schema.get$ref() != null) {
schema = ModelUtils.getReferencedSchema(openAPI, schema);
Expand Down Expand Up @@ -8498,34 +8482,6 @@ public boolean isTypeErasedGenerics() {
*/
protected String handleSpecialCharacters(String name) { return name; }

/**
* Used to ensure that null or Schema is returned given an input Boolean/Schema/null
* This will be used in openapi 3.1.0 spec processing to ensure that Booleans become Schemas
* Because our generators only understand Schemas
* Note: use getIsBooleanSchemaTrue or getIsBooleanSchemaFalse on the IJsonSchemaValidationProperties
* if you need to be able to detect if the original schema's value was true or false
*
* @param schema the input Boolean or Schema data to convert to a Schema
* @return Schema the input data converted to a Schema if possible
*/
protected Schema getSchemaFromBooleanOrSchema(Object schema) {
if (schema == null) {
return null;
} else if (schema instanceof Boolean) {
if (Boolean.TRUE.equals(schema)) {
return trueSchema;
} else if (Boolean.FALSE.equals(schema)) {
return falseSchema;
}
// null case
return null;
} else if (schema instanceof Schema) {
return (Schema) schema;
} else {
throw new IllegalArgumentException("Invalid schema type; type must be Boolean or Schema");
}
}

public void setAutosetConstants(boolean autosetConstants) {
this.autosetConstants = autosetConstants;
}
Expand Down