Skip to content

Commit a08efcf

Browse files
committed
fix linting
1 parent 7f329ad commit a08efcf

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{!
2+
Renders the Go base (unwrapped) type for a property, accounting for nullable
3+
additionalProperties. Used in getter/setter signatures where upstream emits
4+
the vendor base type. For map types whose additionalProperties schema is
5+
nullable, upstream ignores nullable=true and produces map[string]string
6+
instead of map[string]*string. This partial restores the missing pointer
7+
in that case, and otherwise emits the upstream base type unchanged.
8+
}}{{#isMap}}{{#additionalProperties.isNullable}}map[string]*{{{additionalProperties.dataType}}}{{/additionalProperties.isNullable}}{{^additionalProperties.isNullable}}{{vendorExtensions.x-go-base-type}}{{/additionalProperties.isNullable}}{{/isMap}}{{^isMap}}{{vendorExtensions.x-go-base-type}}{{/isMap}}

languages/golang/templates/model_simple.mustache

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ func New{{classname}}WithDefaults() *{{classname}} {
9696
{{#required}}
9797
// Get{{name}} returns the {{name}} field value
9898
{{#isNullable}}
99-
// If the value is explicit nil, the zero value for {{>field_type}} will be returned
99+
// If the value is explicit nil, the zero value for {{>field_type_base}} will be returned
100100
{{/isNullable}}
101101
{{#deprecated}}
102102
// Deprecated
103103
{{/deprecated}}
104-
func (o *{{classname}}) Get{{name}}() {{>field_type}} {
104+
func (o *{{classname}}) Get{{name}}() {{>field_type_base}} {
105105
if o == nil{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
106-
var ret {{>field_type}}
106+
var ret {{>field_type_base}}
107107
return ret
108108
}
109109

@@ -128,13 +128,13 @@ func (o *{{classname}}) Get{{name}}() {{>field_type}} {
128128
{{#deprecated}}
129129
// Deprecated
130130
{{/deprecated}}
131-
func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{>field_type}}, bool) {
131+
func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{>field_type_base}}, bool) {
132132
if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
133133
{{^isFreeFormObject}}
134134
return nil, false
135135
{{/isFreeFormObject}}
136136
{{#isFreeFormObject}}
137-
return {{vendorExtensions.x-go-base-type}}{}, false
137+
return {{>field_type_base}}{}, false
138138
{{/isFreeFormObject}}
139139
}
140140
{{#isNullable}}
@@ -154,7 +154,7 @@ func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/is
154154
{{#deprecated}}
155155
// Deprecated
156156
{{/deprecated}}
157-
func (o *{{classname}}) Set{{name}}(v {{>field_type}}) {
157+
func (o *{{classname}}) Set{{name}}(v {{>field_type_base}}) {
158158
{{#isNullable}}
159159
{{#vendorExtensions.x-golang-is-container}}
160160
o.{{name}} = v
@@ -185,9 +185,9 @@ func (o *{{classname}}) GetDefault{{nameInPascalCase}}() interface{} {
185185
{{#deprecated}}
186186
// Deprecated
187187
{{/deprecated}}
188-
func (o *{{classname}}) Get{{name}}() {{>field_type}} {
188+
func (o *{{classname}}) Get{{name}}() {{>field_type_base}} {
189189
if o == nil{{^isNullable}} || IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
190-
var ret {{>field_type}}
190+
var ret {{>field_type_base}}
191191
return ret
192192
}
193193
{{#isNullable}}
@@ -211,13 +211,13 @@ func (o *{{classname}}) Get{{name}}() {{>field_type}} {
211211
{{#deprecated}}
212212
// Deprecated
213213
{{/deprecated}}
214-
func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{>field_type}}, bool) {
214+
func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{>field_type_base}}, bool) {
215215
if o == nil{{^isNullable}} || IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
216216
{{^isFreeFormObject}}
217217
return nil, false
218218
{{/isFreeFormObject}}
219219
{{#isFreeFormObject}}
220-
return {{vendorExtensions.x-go-base-type}}{}, false
220+
return {{>field_type_base}}{}, false
221221
{{/isFreeFormObject}}
222222
}
223223
{{#isNullable}}
@@ -242,11 +242,11 @@ func (o *{{classname}}) Has{{name}}() bool {
242242
return false
243243
}
244244

245-
// Set{{name}} gets a reference to the given {{>field_type}} and assigns it to the {{name}} field.
245+
// Set{{name}} gets a reference to the given {{dataType}} and assigns it to the {{name}} field.
246246
{{#deprecated}}
247247
// Deprecated
248248
{{/deprecated}}
249-
func (o *{{classname}}) Set{{name}}(v {{>field_type}}) {
249+
func (o *{{classname}}) Set{{name}}(v {{>field_type_base}}) {
250250
{{#isNullable}}
251251
{{#vendorExtensions.x-golang-is-container}}
252252
o.{{name}} = v

0 commit comments

Comments
 (0)