Skip to content

Commit 8a02aba

Browse files
committed
Implement GetActualInstanceValue method
1 parent dd67423 commit 8a02aba

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

modules/openapi-generator/src/main/resources/go/client.mustache

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
137137

138138
func parameterValueToString( obj interface{}, key string ) string {
139139
if reflect.TypeOf(obj).Kind() != reflect.Ptr {
140+
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
141+
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
142+
}
143+
140144
return fmt.Sprintf("%v", obj)
141145
}
142146
var param,ok = obj.(MappedNullable)

modules/openapi-generator/src/main/resources/go/model_oneof.mustache

+12
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,16 @@ func (obj *{{classname}}) GetActualInstance() (interface{}) {
145145
return nil
146146
}
147147

148+
// Get the actual instance value
149+
func (obj {{classname}}) GetActualInstanceValue() (interface{}) {
150+
{{#oneOf}}
151+
if obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil {
152+
return *obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}
153+
}
154+
155+
{{/oneOf}}
156+
// all schemas are nil
157+
return nil
158+
}
159+
148160
{{>nullable_model}}

0 commit comments

Comments
 (0)