Skip to content

Commit dcd7bed

Browse files
authored
[Go][Experimental] Rename extensions from x-basetype to x-go-base-type (#5691)
* rename go vendor extension * update go exp petstore samples oas3
1 parent b242b4a commit dcd7bed

20 files changed

Lines changed: 656 additions & 449 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public CodegenProperty fromProperty(String name, Schema p) {
153153
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
154154
// The superclass determines the list of required golang imports. The actual list of imports
155155
// depends on which types are used, some of which are changed in the code below (but then preserved
156-
// and used through x-basetype in templates). So super.postProcessModels
156+
// and used through x-go-base-type in templates). So super.postProcessModels
157157
// must be invoked at the beginning of this method.
158158
objs = super.postProcessModels(objs);
159159

@@ -167,7 +167,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
167167
}
168168

169169
for (CodegenProperty param : model.vars) {
170-
param.vendorExtensions.put("x-basetype", param.dataType);
170+
param.vendorExtensions.put("x-go-base-type", param.dataType);
171171
if (!param.isNullable || param.isMapContainer || param.isListContainer) {
172172
continue;
173173
}

modules/openapi-generator/src/main/resources/go-experimental/model.mustache

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ func New{{classname}}WithDefaults() *{{classname}} {
112112
{{#required}}
113113
// Get{{name}} returns the {{name}} field value
114114
{{#isNullable}}
115-
// If the value is explicit nil, the zero value for {{vendorExtensions.x-basetype}} will be returned
115+
// If the value is explicit nil, the zero value for {{vendorExtensions.x-go-base-type}} will be returned
116116
{{/isNullable}}
117-
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-basetype}} {
117+
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
118118
if o == nil {{#isNullable}}{{^isContainer}}|| o.{{name}}.Get() == nil{{/isContainer}}{{/isNullable}} {
119-
var ret {{vendorExtensions.x-basetype}}
119+
var ret {{vendorExtensions.x-go-base-type}}
120120
return ret
121121
}
122122

@@ -138,7 +138,7 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-basetype}} {
138138
{{#isNullable}}
139139
// NOTE: If the value is an explicit nil, `nil, true` will be returned
140140
{{/isNullable}}
141-
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-basetype}}, bool) {
141+
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool) {
142142
if o == nil {{#isNullable}}{{#isContainer}}|| o.{{name}} == nil{{/isContainer}}{{/isNullable}} {
143143
return nil, false
144144
}
@@ -156,7 +156,7 @@ func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-basetype}}, bool)
156156
}
157157

158158
// Set{{name}} sets field value
159-
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-basetype}}) {
159+
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
160160
{{#isNullable}}
161161
{{#isContainer}}
162162
o.{{name}} = v
@@ -173,9 +173,9 @@ func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-basetype}}) {
173173
{{/required}}
174174
{{^required}}
175175
// Get{{name}} returns the {{name}} field value if set, zero value otherwise{{#isNullable}} (both if not set or set to explicit null){{/isNullable}}.
176-
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-basetype}} {
176+
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
177177
if o == nil {{^isNullable}}|| o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{^isContainer}}|| o.{{name}}.Get() == nil{{/isContainer}}{{/isNullable}} {
178-
var ret {{vendorExtensions.x-basetype}}
178+
var ret {{vendorExtensions.x-go-base-type}}
179179
return ret
180180
}
181181
{{#isNullable}}
@@ -196,7 +196,7 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-basetype}} {
196196
{{#isNullable}}
197197
// NOTE: If the value is an explicit nil, `nil, true` will be returned
198198
{{/isNullable}}
199-
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-basetype}}, bool) {
199+
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool) {
200200
if o == nil {{^isNullable}}|| o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{#isContainer}}|| o.{{name}} == nil{{/isContainer}}{{/isNullable}} {
201201
return nil, false
202202
}
@@ -223,7 +223,7 @@ func (o *{{classname}}) Has{{name}}() bool {
223223
}
224224

225225
// Set{{name}} gets a reference to the given {{dataType}} and assigns it to the {{name}} field.
226-
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-basetype}}) {
226+
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
227227
{{#isNullable}}
228228
{{#isContainer}}
229229
o.{{name}} = v

modules/openapi-generator/src/main/resources/go-experimental/model_doc.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ but it doesn't guarantee that properties required by API are set
3636
{{#vars}}
3737
### Get{{name}}
3838

39-
`func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-basetype}}`
39+
`func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}}`
4040

4141
Get{{name}} returns the {{name}} field if non-nil, zero value otherwise.
4242

4343
### Get{{name}}Ok
4444

45-
`func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-basetype}}, bool)`
45+
`func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool)`
4646

4747
Get{{name}}Ok returns a tuple with the {{name}} field if it's non-nil, zero value otherwise
4848
and a boolean to check if the value has been set.
4949

5050
### Set{{name}}
5151

52-
`func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-basetype}})`
52+
`func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}})`
5353

5454
Set{{name}} sets {{name}} field to given value.
5555

samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Apple.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ GetCultivar returns the Cultivar field if non-nil, zero value otherwise.
3434

3535
### GetCultivarOk
3636

37-
`func (o *Apple) GetCultivarOk() (string, bool)`
37+
`func (o *Apple) GetCultivarOk() (*string, bool)`
3838

3939
GetCultivarOk returns a tuple with the Cultivar field if it's non-nil, zero value otherwise
4040
and a boolean to check if the value has been set.
4141

42-
### HasCultivar
42+
### SetCultivar
4343

44-
`func (o *Apple) HasCultivar() bool`
44+
`func (o *Apple) SetCultivar(v string)`
4545

46-
HasCultivar returns a boolean if a field has been set.
46+
SetCultivar sets Cultivar field to given value.
4747

48-
### SetCultivar
48+
### HasCultivar
4949

50-
`func (o *Apple) SetCultivar(v string)`
50+
`func (o *Apple) HasCultivar() bool`
5151

52-
SetCultivar gets a reference to the given string and assigns it to the Cultivar field.
52+
HasCultivar returns a boolean if a field has been set.
5353

5454
### GetColor
5555

@@ -59,22 +59,22 @@ GetColor returns the Color field if non-nil, zero value otherwise.
5959

6060
### GetColorOk
6161

62-
`func (o *Apple) GetColorOk() (string, bool)`
62+
`func (o *Apple) GetColorOk() (*string, bool)`
6363

6464
GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise
6565
and a boolean to check if the value has been set.
6666

67-
### HasColor
67+
### SetColor
6868

69-
`func (o *Apple) HasColor() bool`
69+
`func (o *Apple) SetColor(v string)`
7070

71-
HasColor returns a boolean if a field has been set.
71+
SetColor sets Color field to given value.
7272

73-
### SetColor
73+
### HasColor
7474

75-
`func (o *Apple) SetColor(v string)`
75+
`func (o *Apple) HasColor() bool`
7676

77-
SetColor gets a reference to the given string and assigns it to the Color field.
77+
HasColor returns a boolean if a field has been set.
7878

7979

8080
### AsFruit

samples/openapi3/client/petstore/go-experimental/go-petstore/docs/AppleReq.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,17 @@ GetCultivar returns the Cultivar field if non-nil, zero value otherwise.
3434

3535
### GetCultivarOk
3636

37-
`func (o *AppleReq) GetCultivarOk() (string, bool)`
37+
`func (o *AppleReq) GetCultivarOk() (*string, bool)`
3838

3939
GetCultivarOk returns a tuple with the Cultivar field if it's non-nil, zero value otherwise
4040
and a boolean to check if the value has been set.
4141

42-
### HasCultivar
43-
44-
`func (o *AppleReq) HasCultivar() bool`
45-
46-
HasCultivar returns a boolean if a field has been set.
47-
4842
### SetCultivar
4943

5044
`func (o *AppleReq) SetCultivar(v string)`
5145

52-
SetCultivar gets a reference to the given string and assigns it to the Cultivar field.
46+
SetCultivar sets Cultivar field to given value.
47+
5348

5449
### GetMealy
5550

@@ -59,22 +54,22 @@ GetMealy returns the Mealy field if non-nil, zero value otherwise.
5954

6055
### GetMealyOk
6156

62-
`func (o *AppleReq) GetMealyOk() (bool, bool)`
57+
`func (o *AppleReq) GetMealyOk() (*bool, bool)`
6358

6459
GetMealyOk returns a tuple with the Mealy field if it's non-nil, zero value otherwise
6560
and a boolean to check if the value has been set.
6661

67-
### HasMealy
62+
### SetMealy
6863

69-
`func (o *AppleReq) HasMealy() bool`
64+
`func (o *AppleReq) SetMealy(v bool)`
7065

71-
HasMealy returns a boolean if a field has been set.
66+
SetMealy sets Mealy field to given value.
7267

73-
### SetMealy
68+
### HasMealy
7469

75-
`func (o *AppleReq) SetMealy(v bool)`
70+
`func (o *AppleReq) HasMealy() bool`
7671

77-
SetMealy gets a reference to the given bool and assigns it to the Mealy field.
72+
HasMealy returns a boolean if a field has been set.
7873

7974

8075
### AsFruitReq

samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Banana.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ GetLengthCm returns the LengthCm field if non-nil, zero value otherwise.
3434

3535
### GetLengthCmOk
3636

37-
`func (o *Banana) GetLengthCmOk() (float32, bool)`
37+
`func (o *Banana) GetLengthCmOk() (*float32, bool)`
3838

3939
GetLengthCmOk returns a tuple with the LengthCm field if it's non-nil, zero value otherwise
4040
and a boolean to check if the value has been set.
4141

42-
### HasLengthCm
42+
### SetLengthCm
4343

44-
`func (o *Banana) HasLengthCm() bool`
44+
`func (o *Banana) SetLengthCm(v float32)`
4545

46-
HasLengthCm returns a boolean if a field has been set.
46+
SetLengthCm sets LengthCm field to given value.
4747

48-
### SetLengthCm
48+
### HasLengthCm
4949

50-
`func (o *Banana) SetLengthCm(v float32)`
50+
`func (o *Banana) HasLengthCm() bool`
5151

52-
SetLengthCm gets a reference to the given float32 and assigns it to the LengthCm field.
52+
HasLengthCm returns a boolean if a field has been set.
5353

5454
### GetColor
5555

@@ -59,22 +59,22 @@ GetColor returns the Color field if non-nil, zero value otherwise.
5959

6060
### GetColorOk
6161

62-
`func (o *Banana) GetColorOk() (string, bool)`
62+
`func (o *Banana) GetColorOk() (*string, bool)`
6363

6464
GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise
6565
and a boolean to check if the value has been set.
6666

67-
### HasColor
67+
### SetColor
6868

69-
`func (o *Banana) HasColor() bool`
69+
`func (o *Banana) SetColor(v string)`
7070

71-
HasColor returns a boolean if a field has been set.
71+
SetColor sets Color field to given value.
7272

73-
### SetColor
73+
### HasColor
7474

75-
`func (o *Banana) SetColor(v string)`
75+
`func (o *Banana) HasColor() bool`
7676

77-
SetColor gets a reference to the given string and assigns it to the Color field.
77+
HasColor returns a boolean if a field has been set.
7878

7979

8080
### AsFruit

samples/openapi3/client/petstore/go-experimental/go-petstore/docs/BananaReq.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,17 @@ GetLengthCm returns the LengthCm field if non-nil, zero value otherwise.
3434

3535
### GetLengthCmOk
3636

37-
`func (o *BananaReq) GetLengthCmOk() (float32, bool)`
37+
`func (o *BananaReq) GetLengthCmOk() (*float32, bool)`
3838

3939
GetLengthCmOk returns a tuple with the LengthCm field if it's non-nil, zero value otherwise
4040
and a boolean to check if the value has been set.
4141

42-
### HasLengthCm
43-
44-
`func (o *BananaReq) HasLengthCm() bool`
45-
46-
HasLengthCm returns a boolean if a field has been set.
47-
4842
### SetLengthCm
4943

5044
`func (o *BananaReq) SetLengthCm(v float32)`
5145

52-
SetLengthCm gets a reference to the given float32 and assigns it to the LengthCm field.
46+
SetLengthCm sets LengthCm field to given value.
47+
5348

5449
### GetSweet
5550

@@ -59,22 +54,22 @@ GetSweet returns the Sweet field if non-nil, zero value otherwise.
5954

6055
### GetSweetOk
6156

62-
`func (o *BananaReq) GetSweetOk() (bool, bool)`
57+
`func (o *BananaReq) GetSweetOk() (*bool, bool)`
6358

6459
GetSweetOk returns a tuple with the Sweet field if it's non-nil, zero value otherwise
6560
and a boolean to check if the value has been set.
6661

67-
### HasSweet
62+
### SetSweet
6863

69-
`func (o *BananaReq) HasSweet() bool`
64+
`func (o *BananaReq) SetSweet(v bool)`
7065

71-
HasSweet returns a boolean if a field has been set.
66+
SetSweet sets Sweet field to given value.
7267

73-
### SetSweet
68+
### HasSweet
7469

75-
`func (o *BananaReq) SetSweet(v bool)`
70+
`func (o *BananaReq) HasSweet() bool`
7671

77-
SetSweet gets a reference to the given bool and assigns it to the Sweet field.
72+
HasSweet returns a boolean if a field has been set.
7873

7974

8075
### AsFruitReq

0 commit comments

Comments
 (0)