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

v2 codegenProperty cleanup #102

Merged
merged 98 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
09e1ada
Adds allOf anyOf oneOf not to codegenProp + Model
spacether Dec 7, 2022
15fdbd4
Replaces all template usage of composedSchemas with allOf/anyOf/oneOf
spacether Dec 7, 2022
d1313fb
Removes CodegenComposedSchemas
spacether Dec 7, 2022
14105ab
Removes usage of getComposedSchemas
spacether Dec 7, 2022
1eaee4a
Removes getter and setter
spacether Dec 7, 2022
2e55c9a
Removes more unused methods
spacether Dec 7, 2022
5e05c12
Removes dataFormat + datatypeWithEnum
spacether Dec 7, 2022
e5eb324
Removes dataTupe template usage
spacether Dec 7, 2022
ff6c4af
Removes dataType
spacether Dec 7, 2022
0cdd4fd
Removes isModel
spacether Dec 7, 2022
072e8ab
Removes isPrimitiveType
spacether Dec 7, 2022
5d3d5bd
Further isPrimitiveType removal
spacether Dec 7, 2022
51dd9fa
Removes defaultValueWithParam
spacether Dec 7, 2022
5ea7f14
Removes containerType
spacether Dec 7, 2022
bdf37db
Removes jsonSchema
spacether Dec 7, 2022
5d1ab5f
Removes min + max
spacether Dec 7, 2022
32997f3
Removes hasMoreNonReadOnly
spacether Dec 7, 2022
54f90a4
Removes isContainer
spacether Dec 7, 2022
04de77b
Removes isFreeFormObject
spacether Dec 7, 2022
5a264ad
Removes isInnerEnum
spacether Dec 7, 2022
6a36ad8
Removes mostInnerItems
spacether Dec 7, 2022
6486932
Removes isInherited
spacether Dec 7, 2022
2cf5216
Removes enumName
spacether Dec 7, 2022
b0af69d
Removes additionalPropertiesIsAnyType
spacether Dec 7, 2022
51d011a
Adds spec version comment in JsonSchema.java
spacether Dec 7, 2022
23d41e4
Exports python code to defaultCodegen
spacether Dec 8, 2022
af5b500
Removes uniqueItemsBoolean
spacether Dec 8, 2022
b0e9914
Removes updatePropertyForArray
spacether Dec 8, 2022
9086f40
Renames getRequiredVarsMap to getRequiredProperties
spacether Dec 8, 2022
5e96cf5
Adds properties + optionalProperties
spacether Dec 8, 2022
c76b8f3
Switches some vars to properties
spacether Dec 8, 2022
9f7a9d4
Uses LinkedHashMap for property maps to preserve insertion order, use…
spacether Dec 8, 2022
61ae03b
Removes hasVars
spacether Dec 8, 2022
56c939d
Removes hasRequired
spacether Dec 8, 2022
e29bbfc
Uses more properties and optionalProperties
spacether Dec 8, 2022
c8bca84
Partial update using new data sources
spacether Dec 8, 2022
1912547
getitem type hint tweaks
spacether Dec 8, 2022
aa4461c
Improves type hints
spacether Dec 8, 2022
c367aed
Fixes composed property json paths
spacether Dec 8, 2022
7ddd1dc
Removes schemaIsFromAdditionalProperties from fromProperty
spacether Dec 9, 2022
2c22f52
Removes name from fromProperty
spacether Dec 9, 2022
82fb3f7
Fixes tempate typo
spacether Dec 9, 2022
23fe05a
Removes required from fromProperty
spacether Dec 9, 2022
7afb19e
Removes required from fromProperty
spacether Dec 9, 2022
96a8f43
Removes vars + requiredVars and unusedmethods from DefaultCodegen
spacether Dec 9, 2022
d02a2f9
Regenerates sample
spacether Dec 9, 2022
3865b14
Tweaks required object property docs
spacether Dec 9, 2022
5fc609a
Generates docs for required properties with no defining schema, addPr…
spacether Dec 9, 2022
8379e09
Fixes new type hint definitions
spacether Dec 9, 2022
07805db
Renames composed schemas
spacether Dec 9, 2022
558ad33
Fixes schema definition names for content schemas
spacether Dec 9, 2022
b134594
Adds CodegenKey
spacether Dec 10, 2022
94aa2d4
Stops special handling of additionalProperties baseName
spacether Dec 10, 2022
2e0c9c1
Removes nameInCamelCase + nameInSnakeCase, uses CodegenKey in templates
spacether Dec 10, 2022
efcb3a1
Fixes composed schema names
spacether Dec 10, 2022
610db6b
Removes codegenProperty.baseName
spacether Dec 10, 2022
9156ee9
name.name -> name.getName, removes addPropsUnset template var
spacether Dec 10, 2022
a187fe4
Changes key on properties/requiredProperties/optionalProperties form …
spacether Dec 10, 2022
6af1496
Uses key info to prevent invalid names in required property type hint…
spacether Dec 10, 2022
07a3c0b
Removes generateAliasAsModel
spacether Dec 10, 2022
a7e54ec
Further removal of GenerateAliasAsModel
spacether Dec 10, 2022
1ba9d62
Fixes 3 python tests
spacether Dec 11, 2022
a29ea3b
Partial java test fixes
spacether Dec 11, 2022
5b0c7e8
Adds getKey, fixes more java tests
spacether Dec 12, 2022
5362ad7
Removes generate alias as model, updates more java tests
spacether Dec 12, 2022
94faa76
Fixes more java tests
spacether Dec 12, 2022
d28132f
Syntax errors in java tests reduced to 49
spacether Dec 12, 2022
1fa2e49
Reduces java syntax errors down to 40
spacether Dec 12, 2022
e0a76da
Reduces java syntax errors down to 30
spacether Dec 12, 2022
f115b39
Reduces java syntax errors down to 20
spacether Dec 12, 2022
bac71c4
Reduces java syntax errors down to 7
spacether Dec 12, 2022
09ce88f
Reduces java syntax errors down to 0
spacether Dec 12, 2022
6959689
Reduces java syntax errors down to 240
spacether Dec 12, 2022
220f259
Reduces java syntax errors down to 212
spacether Dec 12, 2022
d8ce9a1
Reduces java syntax errors down to 198
spacether Dec 12, 2022
bb4cb51
Reduces java syntax errors down to 184
spacether Dec 12, 2022
e9ebc42
Reduces java syntax errors down to 158
spacether Dec 13, 2022
3c95019
Reduces java syntax errors down to 136
spacether Dec 13, 2022
2c8a422
Reduces java syntax errors down to 98
spacether Dec 14, 2022
4d15dc2
Reduces java syntax errors down to 76
spacether Dec 14, 2022
0ea9a87
Reduces java syntax errors down to 50
spacether Dec 14, 2022
c90c631
Fixes all syntax errors
spacether Dec 14, 2022
01a66af
Removes JavaClient codegentest
spacether Dec 14, 2022
593362c
Removes JavaInheritancetest
spacether Dec 14, 2022
9f47156
Removes JavaModelEnumtest
spacether Dec 14, 2022
77cdc2b
Fixes 2 tests
spacether Dec 14, 2022
187a999
Reduces test failure qty to 33
spacether Dec 14, 2022
9f24039
Reduces test failure qty to 23
spacether Dec 14, 2022
8303f62
Reduces test failure qty to 11
spacether Dec 14, 2022
18cfaf7
Reduces test failure qty to 7
spacether Dec 14, 2022
04d0143
Reduces test failure qty to 3
spacether Dec 15, 2022
1b19417
Reduces test failure qty to 2
spacether Dec 15, 2022
e7d13ee
Reduces test failure qty to 1
spacether Dec 15, 2022
725f4cf
Fixes all java tests
spacether Dec 15, 2022
facc9e8
Removes unused java client tests
spacether Dec 15, 2022
cdf1217
Samples regenerated
spacether Dec 15, 2022
2afe443
Regenerates samples
spacether Dec 15, 2022
7174406
Samples regen again
spacether Dec 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ public class Generate extends OpenApiGeneratorCommand {
@Option(name = {"--enable-post-process-file"}, title = "enable post-processing of files (in generators supporting it)", description = CodegenConstants.ENABLE_POST_PROCESS_FILE_DESC)
private Boolean enablePostProcessFile;

@Option(name = {"--generate-alias-as-model"}, title = "generate alias (array, map) as model", description = CodegenConstants.GENERATE_ALIAS_AS_MODEL_DESC)
private Boolean generateAliasAsModel;

@Option(name = {"--legacy-discriminator-behavior"}, title = "Support legacy logic for evaluating discriminators", description = CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR_DESC)
private Boolean legacyDiscriminatorBehavior;

Expand Down Expand Up @@ -427,10 +424,6 @@ public void execute() {
configurator.setEnablePostProcessFile(enablePostProcessFile);
}

if (generateAliasAsModel != null) {
configurator.setGenerateAliasAsModel(generateAliasAsModel);
}

if (minimalUpdate != null) {
configurator.setEnableMinimalUpdate(minimalUpdate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class WorkflowSettings {
public static final boolean DEFAULT_ENABLE_POST_PROCESS_FILE = false;
public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false;
public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true;
public static final boolean DEFAULT_GENERATE_ALIAS_AS_MODEL = false;
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = null; // this is set by the generator
public static final Map<String, String> DEFAULT_GLOBAL_PROPERTIES = Collections.unmodifiableMap(new HashMap<>());

Expand All @@ -60,7 +59,6 @@ public class WorkflowSettings {
private boolean enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE;
private boolean enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE;
private boolean strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR;
private boolean generateAliasAsModel = DEFAULT_GENERATE_ALIAS_AS_MODEL;
private String templateDir;
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
private String ignoreFileOverride;
Expand All @@ -82,7 +80,6 @@ private WorkflowSettings(Builder builder) {
this.templatingEngineName = builder.templatingEngineName;
this.ignoreFileOverride = builder.ignoreFileOverride;
this.globalProperties = Collections.unmodifiableMap(builder.globalProperties);
this.generateAliasAsModel = builder.generateAliasAsModel;
}

/**
Expand All @@ -109,7 +106,6 @@ public static Builder newBuilder(WorkflowSettings copy) {
builder.validateSpec = copy.isValidateSpec();
builder.enablePostProcessFile = copy.isEnablePostProcessFile();
builder.enableMinimalUpdate = copy.isEnableMinimalUpdate();
builder.generateAliasAsModel = copy.isGenerateAliasAsModel();
builder.strictSpecBehavior = copy.isStrictSpecBehavior();
builder.templatingEngineName = copy.getTemplatingEngineName();
builder.ignoreFileOverride = copy.getIgnoreFileOverride();
Expand Down Expand Up @@ -227,15 +223,6 @@ public boolean isEnableMinimalUpdate() {
return enableMinimalUpdate;
}

/**
* Indicates whether or not the generation should convert aliases (primitives defined as schema for use within documents) as models.
*
* @return <code>true</code> if generate-alias-as-model is enabled, otherwise <code>false</code>.
*/
public boolean isGenerateAliasAsModel() {
return generateAliasAsModel;
}

/**
* Indicates whether or not 'MUST' and 'SHALL' wording in the api specification is strictly adhered to.
* For example, when <code>false</code>, no automatic 'fixes' will be applied to documents which pass validation but don't follow the spec.
Expand Down Expand Up @@ -308,7 +295,6 @@ public static final class Builder {
private Boolean enablePostProcessFile = DEFAULT_ENABLE_POST_PROCESS_FILE;
private Boolean enableMinimalUpdate = DEFAULT_ENABLE_MINIMAL_UPDATE;
private Boolean strictSpecBehavior = DEFAULT_STRICT_SPEC_BEHAVIOR;
private Boolean generateAliasAsModel = DEFAULT_GENERATE_ALIAS_AS_MODEL;
private String templateDir;
private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME;
private String ignoreFileOverride;
Expand Down Expand Up @@ -447,18 +433,6 @@ public Builder withStrictSpecBehavior(Boolean strictSpecBehavior) {
return this;
}

/**
* Sets the {@code generateAliasAsModel} and returns a reference to this Builder so that the methods can be chained together.
* An 'alias' is a primitive type defined as a schema, and this option will attempt to construct a model for that primitive.
*
* @param generateAliasAsModel the {@code generateAliasAsModel} to set
* @return a reference to this Builder
*/
public Builder withGenerateAliasAsModel(Boolean generateAliasAsModel) {
this.generateAliasAsModel = generateAliasAsModel != null ? generateAliasAsModel : Boolean.valueOf(DEFAULT_GENERATE_ALIAS_AS_MODEL);
return this;
}

/**
* Sets the {@code templateDir} and returns a reference to this Builder so that the methods can be chained together.
*
Expand Down Expand Up @@ -586,7 +560,6 @@ public String toString() {
", templatingEngineName='" + templatingEngineName + '\'' +
", ignoreFileOverride='" + ignoreFileOverride + '\'' +
", globalProperties=" + globalProperties +
", generateAliasAsModel=" + generateAliasAsModel +
'}';
}

Expand All @@ -604,7 +577,6 @@ public boolean equals(Object o) {
isEnablePostProcessFile() == that.isEnablePostProcessFile() &&
isEnableMinimalUpdate() == that.isEnableMinimalUpdate() &&
isStrictSpecBehavior() == that.isStrictSpecBehavior() &&
isGenerateAliasAsModel() == that.isGenerateAliasAsModel() &&
Objects.equals(getInputSpec(), that.getInputSpec()) &&
Objects.equals(getOutputDir(), that.getOutputDir()) &&
Objects.equals(getTemplateDir(), that.getTemplateDir()) &&
Expand All @@ -624,7 +596,6 @@ public int hashCode() {
isSkipOperationExample(),
isLogToStderr(),
isValidateSpec(),
isGenerateAliasAsModel(),
isEnablePostProcessFile(),
isEnableMinimalUpdate(),
isStrictSpecBehavior(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ public interface CodegenConfig {

String getTypeDeclaration(Schema schema);

String getTypeDeclaration(String name);

void processOpts();

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

String getIgnoreFilePathOverride();

String toBooleanGetter(String name);

String toSetter(String name);

String toGetter(String name);

String sanitizeName(String name);

void postProcessFile(File file, String fileType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,6 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,

public static final String OPEN_API_SPEC_NAME = "openAPISpecName";

public static final String GENERATE_ALIAS_AS_MODEL = "generateAliasAsModel";
public static final String GENERATE_ALIAS_AS_MODEL_DESC = "Generate model implementation for aliases to map and array schemas. " +
"An 'alias' is an array, map, or list which is defined inline in a OpenAPI document and becomes a model in the generated code. " +
"A 'map' schema is an object that can have undeclared properties, i.e. the 'additionalproperties' attribute is set on that object. " +
"An 'array' schema is a list of sub schemas in a OAS document";

public static final String USE_COMPARE_NET_OBJECTS = "useCompareNetObjects";
public static final String USE_COMPARE_NET_OBJECTS_DESC = "Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class CodegenDiscriminator {
// This is the propertyName as specified in the OpenAPI discriminator object.
private String propertyName;
private String propertyBaseName;
private String propertyGetter;
private String propertyType;
private Map<String, String> mapping;
private boolean isEnum;
Expand Down Expand Up @@ -49,14 +48,6 @@ public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}

public String getPropertyGetter() {
return propertyGetter;
}

public void setPropertyGetter(String propertyGetter) {
this.propertyGetter = propertyGetter;
}

public String getPropertyBaseName() {
return propertyBaseName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.openapitools.codegen;

import java.util.Objects;

public class CodegenKey {
public CodegenKey(String name, boolean nameIsValid, String snakeCaseName, String camelCaseName) {
this.name = name;
this.nameIsValid = nameIsValid;
this.snakeCaseName = snakeCaseName;
this.camelCaseName = camelCaseName;
}

private String name;
private boolean nameIsValid;
private String snakeCaseName;
private String camelCaseName;

public String getName() { return name; }
public boolean getNameIsValid() { return nameIsValid; }
public String getSnakeCaseName() { return snakeCaseName; }
public String getCamelCaseName() { return camelCaseName; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CodegenKey that = (CodegenKey) o;
return Objects.equals(name, that.name) &&
Objects.equals(nameIsValid, that.nameIsValid) &&
Objects.equals(snakeCaseName, that.snakeCaseName) &&
Objects.equals(camelCaseName, that.camelCaseName);
}

@Override
public int hashCode() {
return Objects.hash(name, nameIsValid, snakeCaseName, camelCaseName);
}
}
Loading