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

Commit 696a959

Browse files
committed
Changes IJsonSchemaValidationProperties to JsonSchema because that is the interface that it represents
1 parent eb3b27f commit 696a959

8 files changed

Lines changed: 25 additions & 25 deletions

File tree

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* CodegenModel represents a schema object in a OpenAPI document.
2929
*/
3030
@JsonIgnoreProperties({"parentModel", "interfaceModels"})
31-
public class CodegenModel implements IJsonSchemaValidationProperties {
31+
public class CodegenModel implements JsonSchema {
3232
// The parent model name from the schemas. The parent is determined by inspecting the allOf, anyOf and
3333
// oneOf attributes in the OAS. First codegen inspects 'allOf', then 'anyOf', then 'oneOf'.
3434
// If there are multiple object references in the attribute ('allOf', 'anyOf', 'oneOf'), and one of the

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* A unique parameter is defined by a combination of a name and location.
2525
* Parameters may be located in a path, query, header or cookie.
2626
*/
27-
public class CodegenParameter implements IJsonSchemaValidationProperties {
27+
public class CodegenParameter implements JsonSchema {
2828
public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
2929
isCookieParam, isBodyParam, isContainer,
3030
isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, isDeepObject, isAllowEmptyValue;

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import java.util.*;
2121

22-
public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperties {
22+
public class CodegenProperty implements Cloneable, JsonSchema {
2323
/**
2424
* The value of the 'type' attribute in the OpenAPI schema.
2525
* The per-language codegen logic may change to a language-specific type.

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import java.util.*;
2121

22-
public class CodegenResponse implements IJsonSchemaValidationProperties {
22+
public class CodegenResponse implements JsonSchema {
2323
public final List<CodegenProperty> headers = new ArrayList<CodegenProperty>();
2424
private List<CodegenParameter> responseHeaders = new ArrayList<CodegenParameter>();
2525
public String code;

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,7 @@ public int compare(CodegenProperty one, CodegenProperty another) {
30093009
return m;
30103010
}
30113011

3012-
protected void setAddProps(Schema schema, IJsonSchemaValidationProperties property, String sourceJsonPath) {
3012+
protected void setAddProps(Schema schema, JsonSchema property, String sourceJsonPath) {
30133013
if (schema.equals(new Schema())) {
30143014
// if we are trying to set additionalProperties on an empty schema stop recursing
30153015
return;
@@ -5441,11 +5441,11 @@ private static String generateNextName(String name) {
54415441
}
54425442
}
54435443

5444-
protected void addImports(CodegenModel m, IJsonSchemaValidationProperties type) {
5444+
protected void addImports(CodegenModel m, JsonSchema type) {
54455445
addImports(m.imports, type);
54465446
}
54475447

5448-
protected void addImports(Set<String> importsToBeAddedTo, IJsonSchemaValidationProperties type) {
5448+
protected void addImports(Set<String> importsToBeAddedTo, JsonSchema type) {
54495449
addImports(importsToBeAddedTo, type.getImports(importContainerType, importBaseType, generatorMetadata.getFeatureSet()));
54505450
}
54515451

@@ -5550,12 +5550,12 @@ protected void addVars(CodegenModel m, Map<String, Schema> properties, List<Stri
55505550
/**
55515551
* Add variables (properties) to codegen model (list of properties, various flags, etc)
55525552
*
5553-
* @param m Must be an instance of IJsonSchemaValidationProperties, may be model or property...
5553+
* @param m Must be an instance of JsonSchema, may be model or property...
55545554
* @param vars list of codegen properties (e.g. vars, allVars) to be updated with the new properties
55555555
* @param properties a map of properties (schema)
55565556
* @param mandatory a set of required properties' name
55575557
*/
5558-
protected void addVars(IJsonSchemaValidationProperties m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory, String sourceJsonPath) {
5558+
protected void addVars(JsonSchema m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory, String sourceJsonPath) {
55595559
if (properties == null) {
55605560
return;
55615561
}
@@ -6139,7 +6139,7 @@ public String sanitizeTag(String tag) {
61396139
* Set CodegenParameter boolean flag using CodegenProperty.
61406140
* NOTE: This is deprecated and can be removed in 6.0.0
61416141
* This logic has been folded into the original call sites and long term will be moved into
6142-
* IJsonSchemaValidationProperties.setTypeProperties and overrides like updateModelForObject
6142+
* JsonSchema.setTypeProperties and overrides like updateModelForObject
61436143
*
61446144
* @param parameter Codegen Parameter
61456145
* @param property Codegen property
@@ -7277,7 +7277,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
72777277
return codegenParameter;
72787278
}
72797279

7280-
protected void addRequiredVarsMap(Schema schema, IJsonSchemaValidationProperties property, String sourceJsonPath) {
7280+
protected void addRequiredVarsMap(Schema schema, JsonSchema property, String sourceJsonPath) {
72817281
/*
72827282
this should be called after vars and additionalProperties are set
72837283
Features added by storing codegenProperty values:
@@ -7335,7 +7335,7 @@ protected void addRequiredVarsMap(Schema schema, IJsonSchemaValidationProperties
73357335
}
73367336
}
73377337

7338-
protected void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property, String sourceJsonPath) {
7338+
protected void addVarsRequiredVarsAdditionalProps(Schema schema, JsonSchema property, String sourceJsonPath) {
73397339
setAddProps(schema, property, sourceJsonPath);
73407340
Set<String> mandatory = schema.getRequired() == null ? Collections.emptySet()
73417341
: new TreeSet<>(schema.getRequired());
@@ -7914,7 +7914,7 @@ public List<VendorExtension> getSupportedVendorExtensions() {
79147914
* Used to ensure that null or Schema is returned given an input Boolean/Schema/null
79157915
* This will be used in openapi 3.1.0 spec processing to ensure that Booleans become Schemas
79167916
* Because our generators only understand Schemas
7917-
* Note: use getIsBooleanSchemaTrue or getIsBooleanSchemaFalse on the IJsonSchemaValidationProperties
7917+
* Note: use getIsBooleanSchemaTrue or getIsBooleanSchemaFalse on the JsonSchema
79187918
* if you need to be able to detect if the original schema's value was true or false
79197919
*
79207920
* @param schema the input Boolean or Schema data to convert to a Schema

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java renamed to modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/JsonSchema.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
1515
import org.openapitools.codegen.utils.ModelUtils;
1616

17-
public interface IJsonSchemaValidationProperties {
17+
public interface JsonSchema {
1818
CodegenProperty getContains();
1919

2020
void setContains(CodegenProperty contains);
@@ -216,7 +216,7 @@ public interface IJsonSchemaValidationProperties {
216216
String getFormat();
217217

218218
/**
219-
* Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance
219+
* Syncs all the schema's type properties into the JsonSchema instance
220220
* for now this only supports types without format information
221221
* TODO: in the future move the format handling in here too
222222
* @param p the schema which contains the type info

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import io.swagger.v3.oas.models.tags.Tag;
2929

3030
import org.apache.commons.io.FileUtils;
31+
import org.openapitools.codegen.JsonSchema;
3132
import org.openapitools.codegen.api.TemplatePathLocator;
3233
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
3334
import org.openapitools.codegen.model.ModelMap;
@@ -67,7 +68,6 @@
6768

6869
import static org.openapitools.codegen.utils.OnceLogger.once;
6970
import static org.openapitools.codegen.utils.StringUtils.camelize;
70-
import static org.openapitools.codegen.utils.StringUtils.escape;
7171
import static org.openapitools.codegen.utils.StringUtils.underscore;
7272

7373
public class PythonClientCodegen extends AbstractPythonCodegen {
@@ -741,7 +741,7 @@ are defined in that schema (x.properties). We do this because validation should
741741
they are not.
742742
*/
743743
@Override
744-
protected void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property, String sourceJsonPath){
744+
protected void addVarsRequiredVarsAdditionalProps(Schema schema, JsonSchema property, String sourceJsonPath){
745745
setAddProps(schema, property, sourceJsonPath);
746746
if (ModelUtils.isAnyType(schema) && supportsAdditionalPropertiesWithComposedSchema) {
747747
// if anyType schema has properties then add them
@@ -2251,7 +2251,7 @@ protected Map<String, Schema> getModelNameToSchemaCache() {
22512251
* @param property the property for the above schema
22522252
*/
22532253
@Override
2254-
protected void setAddProps(Schema schema, IJsonSchemaValidationProperties property, String sourceJsonPath){
2254+
protected void setAddProps(Schema schema, JsonSchema property, String sourceJsonPath){
22552255
Schema addPropsSchema = getSchemaFromBooleanOrSchema(schema.getAdditionalProperties());
22562256
if (addPropsSchema == null) {
22572257
return;

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import io.swagger.v3.parser.util.SchemaTypeUtil;
3636
import org.apache.commons.lang3.StringUtils;
3737
import org.openapitools.codegen.CodegenModel;
38-
import org.openapitools.codegen.IJsonSchemaValidationProperties;
38+
import org.openapitools.codegen.JsonSchema;
3939
import org.openapitools.codegen.config.GlobalSettings;
4040
import org.openapitools.codegen.model.ModelMap;
4141
import org.openapitools.codegen.model.ModelsMap;
@@ -1623,8 +1623,8 @@ public static boolean isAnyType(Schema schema) {
16231623
return (schema.get$ref() == null && schema.getType() == null);
16241624
}
16251625

1626-
public static void syncValidationProperties(Schema schema, IJsonSchemaValidationProperties target) {
1627-
// TODO move this method to IJsonSchemaValidationProperties
1626+
public static void syncValidationProperties(Schema schema, JsonSchema target) {
1627+
// TODO move this method to JsonSchema
16281628
if (schema != null && target != null) {
16291629
if (isNullType(schema) || schema.get$ref() != null || isBooleanSchema(schema)) {
16301630
return;
@@ -1668,25 +1668,25 @@ public static void syncValidationProperties(Schema schema, IJsonSchemaValidation
16681668
}
16691669
}
16701670

1671-
private static void setArrayValidations(Integer minItems, Integer maxItems, Boolean uniqueItems, IJsonSchemaValidationProperties target) {
1671+
private static void setArrayValidations(Integer minItems, Integer maxItems, Boolean uniqueItems, JsonSchema target) {
16721672
if (minItems != null) target.setMinItems(minItems);
16731673
if (maxItems != null) target.setMaxItems(maxItems);
16741674
if (uniqueItems != null) target.setUniqueItems(uniqueItems);
16751675
if (uniqueItems != null) target.setUniqueItemsBoolean(uniqueItems);
16761676
}
16771677

1678-
private static void setObjectValidations(Integer minProperties, Integer maxProperties, IJsonSchemaValidationProperties target) {
1678+
private static void setObjectValidations(Integer minProperties, Integer maxProperties, JsonSchema target) {
16791679
if (minProperties != null) target.setMinProperties(minProperties);
16801680
if (maxProperties != null) target.setMaxProperties(maxProperties);
16811681
}
16821682

1683-
private static void setStringValidations(Integer minLength, Integer maxLength, String pattern, IJsonSchemaValidationProperties target) {
1683+
private static void setStringValidations(Integer minLength, Integer maxLength, String pattern, JsonSchema target) {
16841684
if (minLength != null) target.setMinLength(minLength);
16851685
if (maxLength != null) target.setMaxLength(maxLength);
16861686
if (pattern != null) target.setPattern(pattern);
16871687
}
16881688

1689-
private static void setNumericValidations(Schema schema, BigDecimal multipleOf, BigDecimal minimum, BigDecimal maximum, Boolean exclusiveMinimum, Boolean exclusiveMaximum, IJsonSchemaValidationProperties target) {
1689+
private static void setNumericValidations(Schema schema, BigDecimal multipleOf, BigDecimal minimum, BigDecimal maximum, Boolean exclusiveMinimum, Boolean exclusiveMaximum, JsonSchema target) {
16901690
if (multipleOf != null) target.setMultipleOf(multipleOf);
16911691
if (minimum != null) {
16921692
if (isIntegerSchema(schema)) {

0 commit comments

Comments
 (0)