forked from loafle/openapi-generator-original
add tests for go oenof datetime (#13713)
This commit is contained in:
parent
a248ae047c
commit
02d99eaf12
@ -2023,3 +2023,8 @@ components:
|
|||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
format: binary
|
format: binary
|
||||||
|
OneOfPrimitiveTypes:
|
||||||
|
oneOf:
|
||||||
|
- type: string
|
||||||
|
- format: date-time
|
||||||
|
type: string
|
||||||
|
@ -62,6 +62,7 @@ docs/NullableClass.md
|
|||||||
docs/NumberOnly.md
|
docs/NumberOnly.md
|
||||||
docs/OneOfPrimitiveType.md
|
docs/OneOfPrimitiveType.md
|
||||||
docs/OneOfPrimitiveTypeChild.md
|
docs/OneOfPrimitiveTypeChild.md
|
||||||
|
docs/OneOfPrimitiveTypes.md
|
||||||
docs/Order.md
|
docs/Order.md
|
||||||
docs/OuterComposite.md
|
docs/OuterComposite.md
|
||||||
docs/OuterEnum.md
|
docs/OuterEnum.md
|
||||||
@ -131,6 +132,7 @@ model_nullable_class.go
|
|||||||
model_number_only.go
|
model_number_only.go
|
||||||
model_one_of_primitive_type.go
|
model_one_of_primitive_type.go
|
||||||
model_one_of_primitive_type_child.go
|
model_one_of_primitive_type_child.go
|
||||||
|
model_one_of_primitive_types.go
|
||||||
model_order.go
|
model_order.go
|
||||||
model_outer_composite.go
|
model_outer_composite.go
|
||||||
model_outer_enum.go
|
model_outer_enum.go
|
||||||
|
@ -168,6 +168,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [NumberOnly](docs/NumberOnly.md)
|
- [NumberOnly](docs/NumberOnly.md)
|
||||||
- [OneOfPrimitiveType](docs/OneOfPrimitiveType.md)
|
- [OneOfPrimitiveType](docs/OneOfPrimitiveType.md)
|
||||||
- [OneOfPrimitiveTypeChild](docs/OneOfPrimitiveTypeChild.md)
|
- [OneOfPrimitiveTypeChild](docs/OneOfPrimitiveTypeChild.md)
|
||||||
|
- [OneOfPrimitiveTypes](docs/OneOfPrimitiveTypes.md)
|
||||||
- [Order](docs/Order.md)
|
- [Order](docs/Order.md)
|
||||||
- [OuterComposite](docs/OuterComposite.md)
|
- [OuterComposite](docs/OuterComposite.md)
|
||||||
- [OuterEnum](docs/OuterEnum.md)
|
- [OuterEnum](docs/OuterEnum.md)
|
||||||
|
@ -1984,6 +1984,11 @@ components:
|
|||||||
description: a property to test map of file
|
description: a property to test map of file
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
|
OneOfPrimitiveTypes:
|
||||||
|
oneOf:
|
||||||
|
- type: string
|
||||||
|
- format: date-time
|
||||||
|
type: string
|
||||||
_foo_get_default_response:
|
_foo_get_default_response:
|
||||||
example:
|
example:
|
||||||
string:
|
string:
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
# OneOfPrimitiveTypes
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### NewOneOfPrimitiveTypes
|
||||||
|
|
||||||
|
`func NewOneOfPrimitiveTypes() *OneOfPrimitiveTypes`
|
||||||
|
|
||||||
|
NewOneOfPrimitiveTypes instantiates a new OneOfPrimitiveTypes object
|
||||||
|
This constructor will assign default values to properties that have it defined,
|
||||||
|
and makes sure properties required by API are set, but the set of arguments
|
||||||
|
will change when the set of required properties is changed
|
||||||
|
|
||||||
|
### NewOneOfPrimitiveTypesWithDefaults
|
||||||
|
|
||||||
|
`func NewOneOfPrimitiveTypesWithDefaults() *OneOfPrimitiveTypes`
|
||||||
|
|
||||||
|
NewOneOfPrimitiveTypesWithDefaults instantiates a new OneOfPrimitiveTypes object
|
||||||
|
This constructor will only assign default values to properties that have it defined,
|
||||||
|
but it doesn't guarantee that properties required by API are set
|
||||||
|
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
API version: 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||||
|
|
||||||
|
package petstore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OneOfPrimitiveTypes - struct for OneOfPrimitiveTypes
|
||||||
|
type OneOfPrimitiveTypes struct {
|
||||||
|
String *string
|
||||||
|
TimeTime *time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// stringAsOneOfPrimitiveTypes is a convenience function that returns string wrapped in OneOfPrimitiveTypes
|
||||||
|
func StringAsOneOfPrimitiveTypes(v *string) OneOfPrimitiveTypes {
|
||||||
|
return OneOfPrimitiveTypes{
|
||||||
|
String: v,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// time.TimeAsOneOfPrimitiveTypes is a convenience function that returns time.Time wrapped in OneOfPrimitiveTypes
|
||||||
|
func TimeTimeAsOneOfPrimitiveTypes(v *time.Time) OneOfPrimitiveTypes {
|
||||||
|
return OneOfPrimitiveTypes{
|
||||||
|
TimeTime: v,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Unmarshal JSON data into one of the pointers in the struct
|
||||||
|
func (dst *OneOfPrimitiveTypes) UnmarshalJSON(data []byte) error {
|
||||||
|
var err error
|
||||||
|
match := 0
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to unmarshal data into TimeTime
|
||||||
|
err = newStrictDecoder(data).Decode(&dst.TimeTime)
|
||||||
|
if err == nil {
|
||||||
|
jsonTimeTime, _ := json.Marshal(dst.TimeTime)
|
||||||
|
if string(jsonTimeTime) == "{}" { // empty struct
|
||||||
|
dst.TimeTime = nil
|
||||||
|
} else {
|
||||||
|
match++
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dst.TimeTime = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if match > 1 { // more than 1 match
|
||||||
|
// reset to nil
|
||||||
|
dst.String = nil
|
||||||
|
dst.TimeTime = nil
|
||||||
|
|
||||||
|
return fmt.Errorf("Data matches more than one schema in oneOf(OneOfPrimitiveTypes)")
|
||||||
|
} else if match == 1 {
|
||||||
|
return nil // exactly one match
|
||||||
|
} else { // no match
|
||||||
|
return fmt.Errorf("Data failed to match schemas in oneOf(OneOfPrimitiveTypes)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
||||||
|
func (src OneOfPrimitiveTypes) MarshalJSON() ([]byte, error) {
|
||||||
|
if src.String != nil {
|
||||||
|
return json.Marshal(&src.String)
|
||||||
|
}
|
||||||
|
|
||||||
|
if src.TimeTime != nil {
|
||||||
|
return json.Marshal(&src.TimeTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil // no data in oneOf schemas
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the actual instance
|
||||||
|
func (obj *OneOfPrimitiveTypes) GetActualInstance() (interface{}) {
|
||||||
|
if obj == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if obj.String != nil {
|
||||||
|
return obj.String
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.TimeTime != nil {
|
||||||
|
return obj.TimeTime
|
||||||
|
}
|
||||||
|
|
||||||
|
// all schemas are nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableOneOfPrimitiveTypes struct {
|
||||||
|
value *OneOfPrimitiveTypes
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableOneOfPrimitiveTypes) Get() *OneOfPrimitiveTypes {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableOneOfPrimitiveTypes) Set(val *OneOfPrimitiveTypes) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableOneOfPrimitiveTypes) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableOneOfPrimitiveTypes) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableOneOfPrimitiveTypes(val *OneOfPrimitiveTypes) *NullableOneOfPrimitiveTypes {
|
||||||
|
return &NullableOneOfPrimitiveTypes{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableOneOfPrimitiveTypes) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableOneOfPrimitiveTypes) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -7,6 +7,6 @@ replace go-petstore => ./go-petstore
|
|||||||
require (
|
require (
|
||||||
github.com/stretchr/testify v1.8.0
|
github.com/stretchr/testify v1.8.0
|
||||||
go-petstore v0.0.0-00010101000000-000000000000
|
go-petstore v0.0.0-00010101000000-000000000000
|
||||||
golang.org/x/net v0.0.0-20221004154528-8021a29435af // indirect
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1
|
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
|
||||||
)
|
)
|
||||||
|
@ -305,6 +305,8 @@ golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced h1:3dYNDff0VT5xj+mbj2XucFst9
|
|||||||
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4=
|
golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4=
|
||||||
golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b h1:tvrvnPFcdzp294diPnrdZZZ8XUt2Tyj7svb7X52iDuU=
|
||||||
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@ -332,6 +334,8 @@ golang.org/x/oauth2 v0.0.0-20220808172628-8227340efae7 h1:dtndE8FcEta75/4kHF3Abp
|
|||||||
golang.org/x/oauth2 v0.0.0-20220808172628-8227340efae7/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
golang.org/x/oauth2 v0.0.0-20220808172628-8227340efae7/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||||
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1 h1:3VPzK7eqH25j7GYw5w6g/GzNRc0/fYtrxz27z1gD4W0=
|
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1 h1:3VPzK7eqH25j7GYw5w6g/GzNRc0/fYtrxz27z1gD4W0=
|
||||||
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user