Remove skipReadonlyPropertiesInInit option (#10269)

* remove skipReadonlyPropertiesInInit option

* fix removal

* more removal

* fix again
This commit is contained in:
William Cheng
2021-08-28 22:43:53 +08:00
committed by GitHub
parent 8818bf260e
commit 7bdbfed467
5 changed files with 0 additions and 46 deletions

View File

@@ -7,4 +7,3 @@ additionalProperties:
packageName: petstore
disallowAdditionalPropertiesIfNotPresent: false
generateInterfaces: true
skipReadonlyPropertiesInInt: false

View File

@@ -15,7 +15,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|skipReadonlyPropertiesInInit|Skip default values to the readOnly properties in the model init function| |true|
|structPrefix|whether to prefix struct with the class name. e.g. DeletePetOpts => PetApiDeletePetOpts| |false|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
|withAWSV4Signature|whether to include AWS v4 signature support| |false|

View File

@@ -388,7 +388,4 @@ public class CodegenConstants {
"If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.";
public static final String USE_ONEOF_DISCRIMINATOR_LOOKUP = "useOneOfDiscriminatorLookup";
public static final String USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC = "Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.";
public static final String SKIP_READONLY_PROPERTIES_IN_INIT = "skipReadonlyPropertiesInInit";
public static final String SKIP_READONLY_PROPERTIES_IN_INIT_DESC = "Skip default values to the readOnly properties in the model init function";
}

View File

@@ -48,7 +48,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
protected String goImportAlias = "openapiclient";
protected boolean isGoSubmodule = false;
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
protected boolean skipReadonlyPropertiesInInt = false;
// A cache to efficiently lookup schema `toModelName()` based on the schema Key
private Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
@@ -113,7 +112,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false"));
cliOptions.add(new CliOption(CodegenConstants.SKIP_READONLY_PROPERTIES_IN_INIT, CodegenConstants.SKIP_READONLY_PROPERTIES_IN_INIT_DESC).defaultValue("true"));
// option to change how we process + set the data in the 'additionalProperties' keyword.
CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean(
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT,
@@ -242,12 +240,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, getUseOneOfDiscriminatorLookup());
}
if (additionalProperties.containsKey(CodegenConstants.SKIP_READONLY_PROPERTIES_IN_INIT)) {
setSkipReadonlyPropertiesInInit(convertPropertyToBooleanAndWriteBack(CodegenConstants.SKIP_READONLY_PROPERTIES_IN_INIT));
} else {
additionalProperties.put(CodegenConstants.SKIP_READONLY_PROPERTIES_IN_INIT, getSkipReadonlyPropertiesInInit());
}
if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
this.setDisallowAdditionalPropertiesIfNotPresent(Boolean.parseBoolean(additionalProperties
.get(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT).toString()));
@@ -274,14 +266,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
return this.useOneOfDiscriminatorLookup;
}
public void setSkipReadonlyPropertiesInInit(boolean skipReadonlyPropertiesInInt) {
this.skipReadonlyPropertiesInInt = skipReadonlyPropertiesInInt;
}
public boolean getSkipReadonlyPropertiesInInit() {
return this.skipReadonlyPropertiesInInt;
}
public void setGoImportAlias(String goImportAlias) {
this.goImportAlias = goImportAlias;
}

View File

@@ -43,17 +43,6 @@ func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} {{dataType}}{{^-last}
{{^required}}
{{#defaultValue}}
{{^vendorExtensions.x-golang-is-container}}
{{#skipReadonlyPropertiesInInt}}
{{#isNullable}}
var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}}
this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}})
{{/isNullable}}
{{^isNullable}}
var {{nameInCamelCase}} {{{dataType}}} = {{{.}}}
this.{{name}} = &{{nameInCamelCase}}
{{/isNullable}}
{{/skipReadonlyPropertiesInInt}}
{{^skipReadonlyPropertiesInInt}}
{{^isReadOnly}}
{{#isNullable}}
var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}}
@@ -64,7 +53,6 @@ func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} {{dataType}}{{^-last}
this.{{name}} = &{{nameInCamelCase}}
{{/isNullable}}
{{/isReadOnly}}
{{/skipReadonlyPropertiesInInt}}
{{/vendorExtensions.x-golang-is-container}}
{{/defaultValue}}
{{/required}}
@@ -80,18 +68,6 @@ func New{{classname}}WithDefaults() *{{classname}} {
{{#vars}}
{{#defaultValue}}
{{^vendorExtensions.x-golang-is-container}}
{{#skipReadonlyPropertiesInInt}}
{{#isNullable}}
{{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}}
var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}}
this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}})
{{/isNullable}}
{{^isNullable}}
var {{nameInCamelCase}} {{{dataType}}} = {{{.}}}
this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}}
{{/isNullable}}
{{/skipReadonlyPropertiesInInt}}
{{^skipReadonlyPropertiesInInt}}
{{^isReadOnly}}
{{#isNullable}}
{{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}}
@@ -103,7 +79,6 @@ func New{{classname}}WithDefaults() *{{classname}} {
this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}}
{{/isNullable}}
{{/isReadOnly}}
{{/skipReadonlyPropertiesInInt}}
{{/vendorExtensions.x-golang-is-container}}
{{/defaultValue}}
{{/vars}}