Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !5175

[go-experimental] Add model constructors to initialize non-container vars with defaults

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/bkabrda/go-experimental-struct-constructor into master 5 years ago
  • Overview 0
  • Commits 8
  • Pipelines 0
  • Changes 185

Created by: bkabrda

This PR adds a constructor to all models that initializes non-container vars with proper defaults. It might also be possible to do container vars in the future, but that is pretty tricky (and also not as widely used to my knowledge).

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09) @bkabrda (2019/07)

Compare
  • master (base)

and
  • latest version
    358648b5
    8 commits, 2 years ago

185 files
+ 3266
- 21

    Preferences

    File browser
    Compare changes
modules/openapi-g‎enerator/src/main‎
java/org/openapitoo‎ls/codegen/languages‎
GoClientExperime‎ntalCodegen.java‎ +56 -4
resources/go‎-experimental‎
model.m‎ustache‎ +38 -0
model_doc‎.mustache‎ +17 -0
sam‎ples‎
client/petstor‎e/…/go-petstore‎
do‎cs‎
AdditionalPrope‎rtiesAnyType.md‎ +17 -0
AdditionalProp‎ertiesArray.md‎ +17 -0
AdditionalPrope‎rtiesBoolean.md‎ +17 -0
AdditionalProp‎ertiesClass.md‎ +17 -0
AdditionalPrope‎rtiesInteger.md‎ +17 -0
AdditionalProp‎ertiesNumber.md‎ +17 -0
AdditionalProp‎ertiesObject.md‎ +17 -0
AdditionalProp‎ertiesString.md‎ +17 -0
Anim‎al.md‎ +18 -1
ApiResp‎onse.md‎ +17 -0
ArrayOfArrayO‎fNumberOnly.md‎ +17 -0
ArrayOfNum‎berOnly.md‎ +17 -0
ArrayT‎est.md‎ +17 -0
BigC‎at.md‎ +17 -0
BigCatA‎llOf.md‎ +17 -0
Capitali‎zation.md‎ +17 -0
Cat‎.md‎ +17 -0
CatAl‎lOf.md‎ +17 -0
Categ‎ory.md‎ +18 -1
ClassM‎odel.md‎ +17 -0
Clie‎nt.md‎ +17 -0
Dog‎.md‎ +17 -0
DogAl‎lOf.md‎ +17 -0
EnumAr‎rays.md‎ +17 -0
EnumT‎est.md‎ +17 -0
FakeA‎pi.md‎ +4 -4
Fil‎e.md‎ +17 -0
FileSchemaT‎estClass.md‎ +17 -0
Format‎Test.md‎ +17 -0
HasOnlyRe‎adOnly.md‎ +17 -0
Lis‎t.md‎ +17 -0
MapTe‎st.md‎ +17 -0
MixedPropertiesAndAddit‎ionalPropertiesClass.md‎ +17 -0
Model200R‎esponse.md‎ +17 -0
Nam‎e.md‎ +17 -0
Number‎Only.md‎ +17 -0
Orde‎r.md‎ +17 -0
OuterCom‎posite.md‎ +17 -0
Pet‎.md‎ +17 -0
ReadOnly‎First.md‎ +17 -0
Retu‎rn.md‎ +17 -0
SpecialMo‎delName.md‎ +17 -0
Tag‎.md‎ +17 -0
TypeHolder‎Default.md‎ +18 -1
TypeHolder‎Example.md‎ +17 -0
Use‎r.md‎ +17 -0
XmlIt‎em.md‎ +17 -0
model_200_‎response.go‎ +17 -0
model_additional_pr‎operties_any_type.go‎ +17 -0
model_additional_p‎roperties_array.go‎ +17 -0
model_additional_pr‎operties_boolean.go‎ +17 -0
model_additional_p‎roperties_class.go‎ +17 -0
model_additional_pr‎operties_integer.go‎ +17 -0
model_additional_p‎roperties_number.go‎ +17 -0
model_additional_p‎roperties_object.go‎ +17 -0
model_additional_p‎roperties_string.go‎ +17 -0
model_a‎nimal.go‎ +22 -0
model_api_‎response.go‎ +17 -0
model_array_of_arra‎y_of_number_only.go‎ +17 -0
model_array_of‎_number_only.go‎ +17 -0
model_arra‎y_test_.go‎ +17 -0
model_bi‎g_cat.go‎ +17 -0
model_big_c‎at_all_of.go‎ +17 -0
model_capit‎alization.go‎ +17 -0
model_‎cat.go‎ +17 -0
model_cat‎_all_of.go‎ +17 -0
model_ca‎tegory.go‎ +20 -0
model_clas‎s_model.go‎ +17 -0
model_c‎lient.go‎ +17 -0
model_‎dog.go‎ +17 -0
model_dog‎_all_of.go‎ +17 -0
model_enum‎_arrays.go‎ +17 -0
model_enu‎m_test_.go‎ +18 -0
model_‎file.go‎ +17 -0
model_file_sche‎ma_test_class.go‎ +17 -0
model_form‎at_test_.go‎ +21 -0
model_has_onl‎y_read_only.go‎ +17 -0
model_‎list.go‎ +17 -0
model_map‎_test_.go‎ +17 -0
model_mixed_properties_and_a‎dditional_properties_class.go‎ +17 -0
model_‎name.go‎ +18 -0
model_numb‎er_only.go‎ +17 -0
model_o‎rder.go‎ +21 -0
model_outer_‎composite.go‎ +17 -0
model_‎pet.go‎ +19 -0
model_read_o‎nly_first.go‎ +17 -0
model_r‎eturn.go‎ +17 -0
model_special‎_model_name.go‎ +17 -0
model_‎tag.go‎ +17 -0
model_type_hol‎der_default.go‎ +26 -0
model_type_hol‎der_example.go‎ +23 -0
model_‎user.go‎ +17 -0
model_xm‎l_item.go‎ +17 -0
openapi3/client‎/…/…/go-petstore‎
do‎cs‎
AdditionalProp‎ertiesClass.md‎ +17 -0
Anim‎al.md‎ +18 -1
ApiResp‎onse.md‎ +17 -0
ArrayOfArrayO‎fNumberOnly.md‎ +17 -0
ArrayOfNum‎berOnly.md‎ +17 -0
ArrayT‎est.md‎ +17 -0
Capitali‎zation.md‎ +17 -0
Cat‎.md‎ +17 -0
CatAl‎lOf.md‎ +17 -0
Categ‎ory.md‎ +18 -1
ClassM‎odel.md‎ +17 -0
Clie‎nt.md‎ +17 -0
Dog‎.md‎ +17 -0
DogAl‎lOf.md‎ +17 -0
EnumAr‎rays.md‎ +17 -0
EnumT‎est.md‎ +19 -2
FakeA‎pi.md‎ +4 -4
Fil‎e.md‎ +17 -0
FileSchemaT‎estClass.md‎ +17 -0
Foo‎.md‎ +18 -1
Format‎Test.md‎ +17 -0
HasOnlyRe‎adOnly.md‎ +17 -0
HealthChec‎kResult.md‎ +17 -0
InlineO‎bject.md‎ +17 -0
InlineOb‎ject1.md‎ +17 -0
InlineOb‎ject2.md‎ +18 -1
InlineOb‎ject3.md‎ +17 -0
InlineOb‎ject4.md‎ +17 -0
InlineOb‎ject5.md‎ +17 -0
InlineRespon‎seDefault.md‎ +17 -0
Lis‎t.md‎ +17 -0
MapTe‎st.md‎ +17 -0
MixedPropertiesAndAddit‎ionalPropertiesClass.md‎ +17 -0
Model200R‎esponse.md‎ +17 -0
Nam‎e.md‎ +17 -0
Nullable‎Class.md‎ +17 -0
Number‎Only.md‎ +17 -0
Orde‎r.md‎ +17 -0
OuterCom‎posite.md‎ +17 -0
Pet‎.md‎ +17 -0
ReadOnly‎First.md‎ +17 -0
Retu‎rn.md‎ +17 -0
SpecialMo‎delName.md‎ +17 -0
Tag‎.md‎ +17 -0
Use‎r.md‎ +17 -0
model_200_‎response.go‎ +17 -0
model__special‎_model_name_.go‎ +17 -0
model_additional_p‎roperties_class.go‎ +17 -0
model_a‎nimal.go‎ +22 -0
model_api_‎response.go‎ +17 -0
model_array_of_arra‎y_of_number_only.go‎ +17 -0
model_array_of‎_number_only.go‎ +17 -0
model_arra‎y_test_.go‎ +17 -0
model_capit‎alization.go‎ +17 -0
model_‎cat.go‎ +17 -0
model_cat‎_all_of.go‎ +17 -0
model_ca‎tegory.go‎ +20 -0
model_clas‎s_model.go‎ +17 -0
model_c‎lient.go‎ +17 -0
model_‎dog.go‎ +17 -0
model_dog‎_all_of.go‎ +17 -0
model_enum‎_arrays.go‎ +17 -0
model_enu‎m_test_.go‎ +26 -0
model_‎file.go‎ +17 -0
model_file_sche‎ma_test_class.go‎ +17 -0
model_‎foo.go‎ +21 -0
model_form‎at_test_.go‎ +21 -0
model_has_onl‎y_read_only.go‎ +17 -0
model_health_c‎heck_result.go‎ +17 -0
model_inlin‎e_object.go‎ +17 -0
model_inline‎_object_1.go‎ +17 -0
model_inline‎_object_2.go‎ +21 -0
model_inline‎_object_3.go‎ +21 -0
model_inline‎_object_4.go‎ +19 -0
model_inline‎_object_5.go‎ +18 -0
model_inline_res‎ponse_default.go‎ +17 -0
model_‎list.go‎ +17 -0
model_map‎_test_.go‎ +17 -0
model_mixed_properties_and_a‎dditional_properties_class.go‎ +17 -0
model_‎name.go‎ +18 -0
model_nulla‎ble_class.go‎ +17 -0
model_numb‎er_only.go‎ +17 -0
model_o‎rder.go‎ +21 -0
model_outer_‎composite.go‎ +17 -0
model_‎pet.go‎ +19 -0
model_read_o‎nly_first.go‎ +17 -0
model_r‎eturn.go‎ +17 -0
model_‎tag.go‎ +17 -0
model_‎user.go‎ +17 -0
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java
+ 56
- 4
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -16,6 +16,7 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
@@ -23,14 +24,12 @@ import org.openapitools.codegen.CodegenSecurity;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.ProcessUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@@ -97,6 +96,59 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
return camelize(toModel(name, false));
}
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return name + '_';
}
@Override
public String toEnumDefaultValue(String value, String datatype) {
String prefix = "";
if (enumClassPrefix) {
prefix = datatype.toUpperCase(Locale.ROOT) + "_";
}
return prefix + value;
}
@Override
public void updateCodegenPropertyEnum(CodegenProperty var) {
// make sure the inline enums have plain defaults (e.g. string, int, float)
String enumDefault = null;
if (var.isEnum && var.defaultValue != null) {
enumDefault = var.defaultValue;
}
super.updateCodegenPropertyEnum(var);
if (var.isEnum && enumDefault != null) {
var.defaultValue = enumDefault;
}
}
@Override
public String toDefaultValue(Schema p) {
p = ModelUtils.getReferencedSchema(this.openAPI, p);
if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
return "\"" + escapeText((String) p.getDefault()) + "\"";
}
return null;
}
return super.toDefaultValue(p);
}
@Override
public CodegenProperty fromProperty(String name, Schema p) {
CodegenProperty prop = super.fromProperty(name, p);
String cc = camelize(prop.name, true);
if (isReservedWord(cc)) {
cc = escapeReservedWord(cc);
}
prop.nameInCamelCase = cc;
return prop;
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java
+ 56
- 4
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -16,6 +16,7 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
@@ -23,14 +24,12 @@ import org.openapitools.codegen.CodegenSecurity;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.ProcessUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@@ -97,6 +96,59 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
return camelize(toModel(name, false));
}
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return name + '_';
}
@Override
public String toEnumDefaultValue(String value, String datatype) {
String prefix = "";
if (enumClassPrefix) {
prefix = datatype.toUpperCase(Locale.ROOT) + "_";
}
return prefix + value;
}
@Override
public void updateCodegenPropertyEnum(CodegenProperty var) {
// make sure the inline enums have plain defaults (e.g. string, int, float)
String enumDefault = null;
if (var.isEnum && var.defaultValue != null) {
enumDefault = var.defaultValue;
}
super.updateCodegenPropertyEnum(var);
if (var.isEnum && enumDefault != null) {
var.defaultValue = enumDefault;
}
}
@Override
public String toDefaultValue(Schema p) {
p = ModelUtils.getReferencedSchema(this.openAPI, p);
if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
return "\"" + escapeText((String) p.getDefault()) + "\"";
}
return null;
}
return super.toDefaultValue(p);
}
@Override
public CodegenProperty fromProperty(String name, Schema p) {
CodegenProperty prop = super.fromProperty(name, p);
String cc = camelize(prop.name, true);
if (isReservedWord(cc)) {
cc = escapeReservedWord(cc);
}
prop.nameInCamelCase = cc;
return prop;
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
modules/openapi-generator/src/main/resources/go-experimental/model.mustache
+ 38
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -52,6 +52,44 @@ type {{classname}} struct {
{{^isEnum}}
{{^vendorExtensions.x-is-one-of-interface}}
// New{{classname}} instantiates a new {{classname}} object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func New{{classname}}({{#vars}}{{#required}}{{nameInCamelCase}} {{dataType}}, {{/required}}{{/vars}}) *{{classname}} {
this := {{classname}}{}
{{#vars}}
{{#required}}
this.{{name}} = {{nameInCamelCase}}
{{/required}}
{{^required}}
{{#defaultValue}}
{{^isContainer}}
var {{nameInCamelCase}} {{{dataType}}} = {{#isNullable}}{{{dataType}}}{Value: {{/isNullable}}{{{.}}}{{#isNullable}} }{{/isNullable}}
this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}}
{{/isContainer}}
{{/defaultValue}}
{{/required}}
{{/vars}}
return &this
}
// New{{classname}}WithDefaults instantiates a new {{classname}} object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func New{{classname}}WithDefaults() *{{classname}} {
this := {{classname}}{}
{{#vars}}
{{#defaultValue}}
{{^isContainer}}
var {{nameInCamelCase}} {{{dataType}}} = {{#isNullable}}{{{dataType}}}{Value: {{/isNullable}}{{{.}}}{{#isNullable}} }{{/isNullable}}
this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}}
{{/isContainer}}
{{/defaultValue}}
{{/vars}}
return &this
}
{{#vars}}
{{#required}}
// Get{{name}} returns the {{name}} field value
modules/openapi-generator/src/main/resources/go-experimental/model_doc.mustache
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -16,6 +16,23 @@ Name | Type | Description | Notes
## Methods
{{^vendorExtensions.x-is-one-of-interface}}
### New{{classname}}
`func New{{classname}}({{#vars}}{{#required}}{{nameInCamelCase}} {{dataType}}, {{/required}}{{/vars}}) *{{classname}}`
New{{classname}} instantiates a new {{classname}} object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### New{{classname}}WithDefaults
`func New{{classname}}WithDefaults() *{{classname}}`
New{{classname}}WithDefaults instantiates a new {{classname}} object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
{{#vars}}
### Get{{name}}
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesAnyType.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -8,6 +8,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesAnyType
`func NewAdditionalPropertiesAnyType() *AdditionalPropertiesAnyType`
NewAdditionalPropertiesAnyType instantiates a new AdditionalPropertiesAnyType object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesAnyTypeWithDefaults
`func NewAdditionalPropertiesAnyTypeWithDefaults() *AdditionalPropertiesAnyType`
NewAdditionalPropertiesAnyTypeWithDefaults instantiates a new AdditionalPropertiesAnyType object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetName
`func (o *AdditionalPropertiesAnyType) GetName() string`
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesArray.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -8,6 +8,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesArray
`func NewAdditionalPropertiesArray() *AdditionalPropertiesArray`
NewAdditionalPropertiesArray instantiates a new AdditionalPropertiesArray object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesArrayWithDefaults
`func NewAdditionalPropertiesArrayWithDefaults() *AdditionalPropertiesArray`
NewAdditionalPropertiesArrayWithDefaults instantiates a new AdditionalPropertiesArray object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetName
`func (o *AdditionalPropertiesArray) GetName() string`
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesBoolean.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -8,6 +8,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesBoolean
`func NewAdditionalPropertiesBoolean() *AdditionalPropertiesBoolean`
NewAdditionalPropertiesBoolean instantiates a new AdditionalPropertiesBoolean object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesBooleanWithDefaults
`func NewAdditionalPropertiesBooleanWithDefaults() *AdditionalPropertiesBoolean`
NewAdditionalPropertiesBooleanWithDefaults instantiates a new AdditionalPropertiesBoolean object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetName
`func (o *AdditionalPropertiesBoolean) GetName() string`
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesClass.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -18,6 +18,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesClass
`func NewAdditionalPropertiesClass() *AdditionalPropertiesClass`
NewAdditionalPropertiesClass instantiates a new AdditionalPropertiesClass object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesClassWithDefaults
`func NewAdditionalPropertiesClassWithDefaults() *AdditionalPropertiesClass`
NewAdditionalPropertiesClassWithDefaults instantiates a new AdditionalPropertiesClass object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetMapString
`func (o *AdditionalPropertiesClass) GetMapString() map[string]string`
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesInteger.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -8,6 +8,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesInteger
`func NewAdditionalPropertiesInteger() *AdditionalPropertiesInteger`
NewAdditionalPropertiesInteger instantiates a new AdditionalPropertiesInteger object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesIntegerWithDefaults
`func NewAdditionalPropertiesIntegerWithDefaults() *AdditionalPropertiesInteger`
NewAdditionalPropertiesIntegerWithDefaults instantiates a new AdditionalPropertiesInteger object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetName
`func (o *AdditionalPropertiesInteger) GetName() string`
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesNumber.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -8,6 +8,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesNumber
`func NewAdditionalPropertiesNumber() *AdditionalPropertiesNumber`
NewAdditionalPropertiesNumber instantiates a new AdditionalPropertiesNumber object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesNumberWithDefaults
`func NewAdditionalPropertiesNumberWithDefaults() *AdditionalPropertiesNumber`
NewAdditionalPropertiesNumberWithDefaults instantiates a new AdditionalPropertiesNumber object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetName
`func (o *AdditionalPropertiesNumber) GetName() string`
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesObject.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -8,6 +8,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesObject
`func NewAdditionalPropertiesObject() *AdditionalPropertiesObject`
NewAdditionalPropertiesObject instantiates a new AdditionalPropertiesObject object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesObjectWithDefaults
`func NewAdditionalPropertiesObjectWithDefaults() *AdditionalPropertiesObject`
NewAdditionalPropertiesObjectWithDefaults instantiates a new AdditionalPropertiesObject object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetName
`func (o *AdditionalPropertiesObject) GetName() string`
samples/client/petstore/go-experimental/go-petstore/docs/AdditionalPropertiesString.md
+ 17
- 0
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -8,6 +8,23 @@ Name | Type | Description | Notes
## Methods
### NewAdditionalPropertiesString
`func NewAdditionalPropertiesString() *AdditionalPropertiesString`
NewAdditionalPropertiesString instantiates a new AdditionalPropertiesString object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAdditionalPropertiesStringWithDefaults
`func NewAdditionalPropertiesStringWithDefaults() *AdditionalPropertiesString`
NewAdditionalPropertiesStringWithDefaults instantiates a new AdditionalPropertiesString object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetName
`func (o *AdditionalPropertiesString) GetName() string`
samples/client/petstore/go-experimental/go-petstore/docs/Animal.md
+ 18
- 1
  • View file @ 358648b5

  • Edit in single-file editor

  • Open in Web IDE


@@ -5,10 +5,27 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ClassName** | Pointer to **string** | |
**Color** | Pointer to **string** | | [optional] [default to red]
**Color** | Pointer to **string** | | [optional] [default to "red"]
## Methods
### NewAnimal
`func NewAnimal(className string, ) *Animal`
NewAnimal instantiates a new Animal object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed
### NewAnimalWithDefaults
`func NewAnimalWithDefaults() *Animal`
NewAnimalWithDefaults instantiates a new Animal object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set
### GetClassName
`func (o *Animal) GetClassName() string`
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
1
Client: Go
1
Client: Go
    Assign labels
  • Manage project labels

Milestone
4.3.0
4.3.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference: OpenAPITools/openapi-generator!5175
Source branch: github/fork/bkabrda/go-experimental-struct-constructor

Menu

Explore Projects Groups Snippets