Implement GetActualInstanceValue method (#20663)

This commit is contained in:
Sander Jochems 2025-02-26 08:54:41 +01:00 committed by GitHub
parent 09df01501a
commit 5757def39b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 182 additions and 0 deletions

View File

@ -137,6 +137,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -145,4 +145,16 @@ func (obj *{{classname}}) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj {{classname}}) GetActualInstanceValue() (interface{}) {
{{#oneOf}}
if obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil {
return *obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}
}
{{/oneOf}}
// all schemas are nil
return nil
}
{{>nullable_model}} {{>nullable_model}}

View File

@ -143,6 +143,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -143,6 +143,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -124,6 +124,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -124,6 +124,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -118,6 +118,20 @@ func (obj *Object) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj Object) GetActualInstanceValue() (interface{}) {
if obj.NestedObject1 != nil {
return *obj.NestedObject1
}
if obj.NestedObject2 != nil {
return *obj.NestedObject2
}
// all schemas are nil
return nil
}
type NullableObject struct { type NullableObject struct {
value *Object value *Object
isSet bool isSet bool

View File

@ -124,6 +124,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -127,6 +127,20 @@ func (obj *Object) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj Object) GetActualInstanceValue() (interface{}) {
if obj.NestedObject1 != nil {
return *obj.NestedObject1
}
if obj.NestedObject2 != nil {
return *obj.NestedObject2
}
// all schemas are nil
return nil
}
type NullableObject struct { type NullableObject struct {
value *Object value *Object
isSet bool isSet bool

View File

@ -143,6 +143,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -127,6 +127,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -128,6 +128,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -146,6 +146,10 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
func parameterValueToString( obj interface{}, key string ) string { func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr { if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
}
return fmt.Sprintf("%v", obj) return fmt.Sprintf("%v", obj)
} }
var param,ok = obj.(MappedNullable) var param,ok = obj.(MappedNullable)

View File

@ -118,6 +118,20 @@ func (obj *Fruit) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj Fruit) GetActualInstanceValue() (interface{}) {
if obj.Apple != nil {
return *obj.Apple
}
if obj.Banana != nil {
return *obj.Banana
}
// all schemas are nil
return nil
}
type NullableFruit struct { type NullableFruit struct {
value *Fruit value *Fruit
isSet bool isSet bool

View File

@ -118,6 +118,20 @@ func (obj *FruitReq) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj FruitReq) GetActualInstanceValue() (interface{}) {
if obj.AppleReq != nil {
return *obj.AppleReq
}
if obj.BananaReq != nil {
return *obj.BananaReq
}
// all schemas are nil
return nil
}
type NullableFruitReq struct { type NullableFruitReq struct {
value *FruitReq value *FruitReq
isSet bool isSet bool

View File

@ -123,6 +123,20 @@ func (obj *IncidentData) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj IncidentData) GetActualInstanceValue() (interface{}) {
if obj.ArrayOfMapmapOfStringAny != nil {
return *obj.ArrayOfMapmapOfStringAny
}
if obj.MapmapOfStringAny != nil {
return *obj.MapmapOfStringAny
}
// all schemas are nil
return nil
}
type NullableIncidentData struct { type NullableIncidentData struct {
value *IncidentData value *IncidentData
isSet bool isSet bool

View File

@ -118,6 +118,20 @@ func (obj *Mammal) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj Mammal) GetActualInstanceValue() (interface{}) {
if obj.Whale != nil {
return *obj.Whale
}
if obj.Zebra != nil {
return *obj.Zebra
}
// all schemas are nil
return nil
}
type NullableMammal struct { type NullableMammal struct {
value *Mammal value *Mammal
isSet bool isSet bool

View File

@ -152,6 +152,24 @@ func (obj *OneOfPrimitiveType) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj OneOfPrimitiveType) GetActualInstanceValue() (interface{}) {
if obj.OneOfPrimitiveTypeChild != nil {
return *obj.OneOfPrimitiveTypeChild
}
if obj.ArrayOfString != nil {
return *obj.ArrayOfString
}
if obj.Int32 != nil {
return *obj.Int32
}
// all schemas are nil
return nil
}
type NullableOneOfPrimitiveType struct { type NullableOneOfPrimitiveType struct {
value *OneOfPrimitiveType value *OneOfPrimitiveType
isSet bool isSet bool

View File

@ -119,6 +119,20 @@ func (obj *OneOfPrimitiveTypes) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj OneOfPrimitiveTypes) GetActualInstanceValue() (interface{}) {
if obj.String != nil {
return *obj.String
}
if obj.TimeTime != nil {
return *obj.TimeTime
}
// all schemas are nil
return nil
}
type NullableOneOfPrimitiveTypes struct { type NullableOneOfPrimitiveTypes struct {
value *OneOfPrimitiveTypes value *OneOfPrimitiveTypes
isSet bool isSet bool

View File

@ -118,6 +118,20 @@ func (obj *OneOfWithComplexType) GetActualInstance() (interface{}) {
return nil return nil
} }
// Get the actual instance value
func (obj OneOfWithComplexType) GetActualInstanceValue() (interface{}) {
if obj.ArrayOfString != nil {
return *obj.ArrayOfString
}
if obj.String != nil {
return *obj.String
}
// all schemas are nil
return nil
}
type NullableOneOfWithComplexType struct { type NullableOneOfWithComplexType struct {
value *OneOfWithComplexType value *OneOfWithComplexType
isSet bool isSet bool