1 Star 0 Fork 0

MrCoder/openapi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
model_api_signature.go 3.17 KB
一键复制 编辑 原始数据 按行查看 历史
MrCoder 提交于 2023-12-22 15:27 +08:00 . update
/*
N32 Handshake API
N32-c Handshake Service. © 2022, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
API version: 1.2.1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package OpenAPI_N32_Handshake
import (
"encoding/json"
"fmt"
)
// ApiSignature - API URI of the service operation
type ApiSignature struct {
CallbackName *CallbackName
String *string
}
// CallbackNameAsApiSignature is a convenience function that returns CallbackName wrapped in ApiSignature
func CallbackNameAsApiSignature(v *CallbackName) ApiSignature {
return ApiSignature{
CallbackName: v,
}
}
// stringAsApiSignature is a convenience function that returns string wrapped in ApiSignature
func StringAsApiSignature(v *string) ApiSignature {
return ApiSignature{
String: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *ApiSignature) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into CallbackName
err = newStrictDecoder(data).Decode(&dst.CallbackName)
if err == nil {
jsonCallbackName, _ := json.Marshal(dst.CallbackName)
if string(jsonCallbackName) == "{}" { // empty struct
dst.CallbackName = nil
} else {
match++
}
} else {
dst.CallbackName = nil
}
// try to unmarshal data into String
err = newStrictDecoder(data).Decode(&dst.String)
if err == nil {
jsonString, _ := json.Marshal(dst.String)
if string(jsonString) == "{}" { // empty struct
dst.String = nil
} else {
match++
}
} else {
dst.String = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.CallbackName = nil
dst.String = nil
return fmt.Errorf("data matches more than one schema in oneOf(ApiSignature)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(ApiSignature)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src ApiSignature) MarshalJSON() ([]byte, error) {
if src.CallbackName != nil {
return json.Marshal(&src.CallbackName)
}
if src.String != nil {
return json.Marshal(&src.String)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *ApiSignature) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.CallbackName != nil {
return obj.CallbackName
}
if obj.String != nil {
return obj.String
}
// all schemas are nil
return nil
}
type NullableApiSignature struct {
value *ApiSignature
isSet bool
}
func (v NullableApiSignature) Get() *ApiSignature {
return v.value
}
func (v *NullableApiSignature) Set(val *ApiSignature) {
v.value = val
v.isSet = true
}
func (v NullableApiSignature) IsSet() bool {
return v.isSet
}
func (v *NullableApiSignature) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableApiSignature(val *ApiSignature) *NullableApiSignature {
return &NullableApiSignature{value: val, isSet: true}
}
func (v NullableApiSignature) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableApiSignature) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/konglinglong/openapi.git
git@gitee.com:konglinglong/openapi.git
konglinglong
openapi
openapi
e403a3c726a4

搜索帮助