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

Commit b97b0f5

Browse files
committed
v2 codegenProperty cleanup (#102)
* Adds allOf anyOf oneOf not to codegenProp + Model * Replaces all template usage of composedSchemas with allOf/anyOf/oneOf * Removes CodegenComposedSchemas * Removes usage of getComposedSchemas * Removes getter and setter * Removes more unused methods * Removes dataFormat + datatypeWithEnum * Removes dataTupe template usage * Removes dataType * Removes isModel * Removes isPrimitiveType * Further isPrimitiveType removal * Removes defaultValueWithParam * Removes containerType * Removes jsonSchema * Removes min + max * Removes hasMoreNonReadOnly * Removes isContainer * Removes isFreeFormObject * Removes isInnerEnum * Removes mostInnerItems * Removes isInherited * Removes enumName * Removes additionalPropertiesIsAnyType * Adds spec version comment in JsonSchema.java * Exports python code to defaultCodegen * Removes uniqueItemsBoolean * Removes updatePropertyForArray * Renames getRequiredVarsMap to getRequiredProperties * Adds properties + optionalProperties * Switches some vars to properties * Uses LinkedHashMap for property maps to preserve insertion order, uses optionalProperties in schema_doc.handlebars * Removes hasVars * Removes hasRequired * Uses more properties and optionalProperties * Partial update using new data sources * getitem type hint tweaks * Improves type hints * Fixes composed property json paths * Removes schemaIsFromAdditionalProperties from fromProperty * Removes name from fromProperty * Fixes tempate typo * Removes required from fromProperty * Removes required from fromProperty * Removes vars + requiredVars and unusedmethods from DefaultCodegen * Regenerates sample * Tweaks required object property docs * Generates docs for required properties with no defining schema, addProps unset * Fixes new type hint definitions * Renames composed schemas * Fixes schema definition names for content schemas * Adds CodegenKey * Stops special handling of additionalProperties baseName * Removes nameInCamelCase + nameInSnakeCase, uses CodegenKey in templates * Fixes composed schema names * Removes codegenProperty.baseName * name.name -> name.getName, removes addPropsUnset template var * Changes key on properties/requiredProperties/optionalProperties form String to CodegenKey * Uses key info to prevent invalid names in required property type hints and new signatures * Removes generateAliasAsModel * Further removal of GenerateAliasAsModel * Fixes 3 python tests * Partial java test fixes * Adds getKey, fixes more java tests * Removes generate alias as model, updates more java tests * Fixes more java tests * Syntax errors in java tests reduced to 49 * Reduces java syntax errors down to 40 * Reduces java syntax errors down to 30 * Reduces java syntax errors down to 20 * Reduces java syntax errors down to 7 * Reduces java syntax errors down to 0 * Reduces java syntax errors down to 240 * Reduces java syntax errors down to 212 * Reduces java syntax errors down to 198 * Reduces java syntax errors down to 184 * Reduces java syntax errors down to 158 * Reduces java syntax errors down to 136 * Reduces java syntax errors down to 98 * Reduces java syntax errors down to 76 * Reduces java syntax errors down to 50 * Fixes all syntax errors * Removes JavaClient codegentest * Removes JavaInheritancetest * Removes JavaModelEnumtest * Fixes 2 tests * Reduces test failure qty to 33 * Reduces test failure qty to 23 * Reduces test failure qty to 11 * Reduces test failure qty to 7 * Reduces test failure qty to 3 * Reduces test failure qty to 2 * Reduces test failure qty to 1 * Fixes all java tests * Removes unused java client tests * Samples regenerated * Regenerates samples * Samples regen again
1 parent 02f8189 commit b97b0f5

File tree

1,360 files changed

+8654
-11040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,360 files changed

+8654
-11040
lines changed

modules/openapi-json-schema-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,6 @@ public class Generate extends OpenApiGeneratorCommand {
263263
@Option(name = {"--enable-post-process-file"}, title = "enable post-processing of files (in generators supporting it)", description = CodegenConstants.ENABLE_POST_PROCESS_FILE_DESC)
264264
private Boolean enablePostProcessFile;
265265

266-
@Option(name = {"--generate-alias-as-model"}, title = "generate alias (array, map) as model", description = CodegenConstants.GENERATE_ALIAS_AS_MODEL_DESC)
267-
private Boolean generateAliasAsModel;
268-
269266
@Option(name = {"--legacy-discriminator-behavior"}, title = "Support legacy logic for evaluating discriminators", description = CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR_DESC)
270267
private Boolean legacyDiscriminatorBehavior;
271268

@@ -427,10 +424,6 @@ public void execute() {
427424
configurator.setEnablePostProcessFile(enablePostProcessFile);
428425
}
429426

430-
if (generateAliasAsModel != null) {
431-
configurator.setGenerateAliasAsModel(generateAliasAsModel);
432-
}
433-
434427
if (minimalUpdate != null) {
435428
configurator.setEnableMinimalUpdate(minimalUpdate);
436429
}

modules/openapi-json-schema-generator-core/src/main/java/org/openapitools/codegen/config/WorkflowSettings.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public class WorkflowSettings {
4545
public static final boolean DEFAULT_ENABLE_POST_PROCESS_FILE = false;
4646
public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false;
4747
public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true;
48-
public static final boolean DEFAULT_GENERATE_ALIAS_AS_MODEL = false;
4948
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = null; // this is set by the generator
5049
public static final Map<String, String> DEFAULT_GLOBAL_PROPERTIES = Collections.unmodifiableMap(new HashMap<>());
5150

@@ -60,7 +59,6 @@ public class WorkflowSettings {
6059
private boolean enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE;
6160
private boolean enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE;
6261
private boolean strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR;
63-
private boolean generateAliasAsModel = DEFAULT_GENERATE_ALIAS_AS_MODEL;
6462
private String templateDir;
6563
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
6664
private String ignoreFileOverride;
@@ -82,7 +80,6 @@ private WorkflowSettings(Builder builder) {
8280
this.templatingEngineName = builder.templatingEngineName;
8381
this.ignoreFileOverride = builder.ignoreFileOverride;
8482
this.globalProperties = Collections.unmodifiableMap(builder.globalProperties);
85-
this.generateAliasAsModel = builder.generateAliasAsModel;
8683
}
8784

8885
/**
@@ -109,7 +106,6 @@ public static Builder newBuilder(WorkflowSettings copy) {
109106
builder.validateSpec = copy.isValidateSpec();
110107
builder.enablePostProcessFile = copy.isEnablePostProcessFile();
111108
builder.enableMinimalUpdate = copy.isEnableMinimalUpdate();
112-
builder.generateAliasAsModel = copy.isGenerateAliasAsModel();
113109
builder.strictSpecBehavior = copy.isStrictSpecBehavior();
114110
builder.templatingEngineName = copy.getTemplatingEngineName();
115111
builder.ignoreFileOverride = copy.getIgnoreFileOverride();
@@ -227,15 +223,6 @@ public boolean isEnableMinimalUpdate() {
227223
return enableMinimalUpdate;
228224
}
229225

230-
/**
231-
* Indicates whether or not the generation should convert aliases (primitives defined as schema for use within documents) as models.
232-
*
233-
* @return <code>true</code> if generate-alias-as-model is enabled, otherwise <code>false</code>.
234-
*/
235-
public boolean isGenerateAliasAsModel() {
236-
return generateAliasAsModel;
237-
}
238-
239226
/**
240227
* Indicates whether or not 'MUST' and 'SHALL' wording in the api specification is strictly adhered to.
241228
* For example, when <code>false</code>, no automatic 'fixes' will be applied to documents which pass validation but don't follow the spec.
@@ -308,7 +295,6 @@ public static final class Builder {
308295
private Boolean enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE;
309296
private Boolean enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE;
310297
private Boolean strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR;
311-
private Boolean generateAliasAsModel = DEFAULT_GENERATE_ALIAS_AS_MODEL;
312298
private String templateDir;
313299
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
314300
private String ignoreFileOverride;
@@ -447,18 +433,6 @@ public Builder withStrictSpecBehavior(Boolean strictSpecBehavior) {
447433
return this;
448434
}
449435

450-
/**
451-
* Sets the {@code generateAliasAsModel} and returns a reference to this Builder so that the methods can be chained together.
452-
* An 'alias' is a primitive type defined as a schema, and this option will attempt to construct a model for that primitive.
453-
*
454-
* @param generateAliasAsModel the {@code generateAliasAsModel} to set
455-
* @return a reference to this Builder
456-
*/
457-
public Builder withGenerateAliasAsModel(Boolean generateAliasAsModel) {
458-
this.generateAliasAsModel = generateAliasAsModel != null ? generateAliasAsModel : Boolean.valueOf(DEFAULT_GENERATE_ALIAS_AS_MODEL);
459-
return this;
460-
}
461-
462436
/**
463437
* Sets the {@code templateDir} and returns a reference to this Builder so that the methods can be chained together.
464438
*
@@ -586,7 +560,6 @@ public String toString() {
586560
", templatingEngineName='" + templatingEngineName + '\'' +
587561
", ignoreFileOverride='" + ignoreFileOverride + '\'' +
588562
", globalProperties=" + globalProperties +
589-
", generateAliasAsModel=" + generateAliasAsModel +
590563
'}';
591564
}
592565

@@ -604,7 +577,6 @@ public boolean equals(Object o) {
604577
isEnablePostProcessFile() == that.isEnablePostProcessFile() &&
605578
isEnableMinimalUpdate() == that.isEnableMinimalUpdate() &&
606579
isStrictSpecBehavior() == that.isStrictSpecBehavior() &&
607-
isGenerateAliasAsModel() == that.isGenerateAliasAsModel() &&
608580
Objects.equals(getInputSpec(), that.getInputSpec()) &&
609581
Objects.equals(getOutputDir(), that.getOutputDir()) &&
610582
Objects.equals(getTemplateDir(), that.getTemplateDir()) &&
@@ -624,7 +596,6 @@ public int hashCode() {
624596
isSkipOperationExample(),
625597
isLogToStderr(),
626598
isValidateSpec(),
627-
isGenerateAliasAsModel(),
628599
isEnablePostProcessFile(),
629600
isEnableMinimalUpdate(),
630601
isStrictSpecBehavior(),

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

Lines changed: 0 additions & 74 deletions
This file was deleted.

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ public interface CodegenConfig {
125125

126126
String getTypeDeclaration(Schema schema);
127127

128-
String getTypeDeclaration(String name);
129-
130128
void processOpts();
131129

132130
List<CliOption> cliOptions();
@@ -348,12 +346,6 @@ public interface CodegenConfig {
348346

349347
String getIgnoreFilePathOverride();
350348

351-
String toBooleanGetter(String name);
352-
353-
String toSetter(String name);
354-
355-
String toGetter(String name);
356-
357349
String sanitizeName(String name);
358350

359351
void postProcessFile(File file, String fileType);

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,6 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
366366

367367
public static final String OPEN_API_SPEC_NAME = "openAPISpecName";
368368

369-
public static final String GENERATE_ALIAS_AS_MODEL = "generateAliasAsModel";
370-
public static final String GENERATE_ALIAS_AS_MODEL_DESC = "Generate model implementation for aliases to map and array schemas. " +
371-
"An 'alias' is an array, map, or list which is defined inline in a OpenAPI document and becomes a model in the generated code. " +
372-
"A 'map' schema is an object that can have undeclared properties, i.e. the 'additionalproperties' attribute is set on that object. " +
373-
"An 'array' schema is a list of sub schemas in a OAS document";
374-
375369
public static final String USE_COMPARE_NET_OBJECTS = "useCompareNetObjects";
376370
public static final String USE_COMPARE_NET_OBJECTS_DESC = "Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.";
377371

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class CodegenDiscriminator {
1919
// This is the propertyName as specified in the OpenAPI discriminator object.
2020
private String propertyName;
2121
private String propertyBaseName;
22-
private String propertyGetter;
2322
private String propertyType;
2423
private Map<String, String> mapping;
2524
private boolean isEnum;
@@ -49,14 +48,6 @@ public void setPropertyName(String propertyName) {
4948
this.propertyName = propertyName;
5049
}
5150

52-
public String getPropertyGetter() {
53-
return propertyGetter;
54-
}
55-
56-
public void setPropertyGetter(String propertyGetter) {
57-
this.propertyGetter = propertyGetter;
58-
}
59-
6051
public String getPropertyBaseName() {
6152
return propertyBaseName;
6253
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.openapitools.codegen;
2+
3+
import java.util.Objects;
4+
5+
public class CodegenKey {
6+
public CodegenKey(String name, boolean nameIsValid, String snakeCaseName, String camelCaseName) {
7+
this.name = name;
8+
this.nameIsValid = nameIsValid;
9+
this.snakeCaseName = snakeCaseName;
10+
this.camelCaseName = camelCaseName;
11+
}
12+
13+
private String name;
14+
private boolean nameIsValid;
15+
private String snakeCaseName;
16+
private String camelCaseName;
17+
18+
public String getName() { return name; }
19+
public boolean getNameIsValid() { return nameIsValid; }
20+
public String getSnakeCaseName() { return snakeCaseName; }
21+
public String getCamelCaseName() { return camelCaseName; }
22+
23+
@Override
24+
public boolean equals(Object o) {
25+
if (this == o) return true;
26+
if (o == null || getClass() != o.getClass()) return false;
27+
CodegenKey that = (CodegenKey) o;
28+
return Objects.equals(name, that.name) &&
29+
Objects.equals(nameIsValid, that.nameIsValid) &&
30+
Objects.equals(snakeCaseName, that.snakeCaseName) &&
31+
Objects.equals(camelCaseName, that.camelCaseName);
32+
}
33+
34+
@Override
35+
public int hashCode() {
36+
return Objects.hash(name, nameIsValid, snakeCaseName, camelCaseName);
37+
}
38+
}

0 commit comments

Comments
 (0)