forked from loafle/openapi-generator-original
[Go] add more tests to cover more cases (#11849)
* more tests for go client * add new files * update samples * add more tests
This commit is contained in:
parent
795db0c19e
commit
7ac90ed98f
3
.gitignore
vendored
3
.gitignore
vendored
@ -263,3 +263,6 @@ samples/openapi3/client/petstore/ruby-faraday/Gemfile.lock
|
||||
|
||||
# Crystal
|
||||
samples/client/petstore/crystal/lib
|
||||
|
||||
# Go
|
||||
samples/openapi3/client/petstore/go/privatekey.pem
|
||||
|
@ -1,6 +1,6 @@
|
||||
generatorName: go
|
||||
outputDir: samples/openapi3/client/petstore/go/go-petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/go
|
||||
additionalProperties:
|
||||
enumClassPrefix: "true"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,6 @@ go 1.13
|
||||
require (
|
||||
github.com/OpenAPITools/openapi-generator/samples/client/petstore/go/go-petstore v0.0.0-00010101000000-000000000000
|
||||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
|
||||
)
|
||||
|
@ -186,6 +186,8 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
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-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -195,6 +197,8 @@ golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 h1:D7nTwh4J0i+5mW4Zjzn5om
|
||||
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg=
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a h1:qfl7ob3DIEs3Ml9oLuPwY2N04gymzAW04WsUQHIClgM=
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||
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-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -52,8 +52,12 @@ docs/MapTest.md
|
||||
docs/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
docs/Model200Response.md
|
||||
docs/Name.md
|
||||
docs/NullableAllOf.md
|
||||
docs/NullableAllOfChild.md
|
||||
docs/NullableClass.md
|
||||
docs/NumberOnly.md
|
||||
docs/OneOfPrimitiveType.md
|
||||
docs/OneOfPrimitiveTypeChild.md
|
||||
docs/Order.md
|
||||
docs/OuterComposite.md
|
||||
docs/OuterEnum.md
|
||||
@ -113,8 +117,12 @@ model_mammal.go
|
||||
model_map_test_.go
|
||||
model_mixed_properties_and_additional_properties_class.go
|
||||
model_name.go
|
||||
model_nullable_all_of.go
|
||||
model_nullable_all_of_child.go
|
||||
model_nullable_class.go
|
||||
model_number_only.go
|
||||
model_one_of_primitive_type.go
|
||||
model_one_of_primitive_type_child.go
|
||||
model_order.go
|
||||
model_outer_composite.go
|
||||
model_outer_enum.go
|
||||
|
@ -158,8 +158,12 @@ Class | Method | HTTP request | Description
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NullableAllOf](docs/NullableAllOf.md)
|
||||
- [NullableAllOfChild](docs/NullableAllOfChild.md)
|
||||
- [NullableClass](docs/NullableClass.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [OneOfPrimitiveType](docs/OneOfPrimitiveType.md)
|
||||
- [OneOfPrimitiveTypeChild](docs/OneOfPrimitiveTypeChild.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [OuterComposite](docs/OuterComposite.md)
|
||||
- [OuterEnum](docs/OuterEnum.md)
|
||||
|
@ -2087,6 +2087,28 @@ components:
|
||||
default: 120
|
||||
type: number
|
||||
type: object
|
||||
NullableAllOfChild:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
NullableAllOf:
|
||||
properties:
|
||||
child:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/NullableAllOfChild'
|
||||
nullable: true
|
||||
type: object
|
||||
OneOfPrimitiveType:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/OneOfPrimitiveTypeChild'
|
||||
- format: int32
|
||||
type: integer
|
||||
OneOfPrimitiveTypeChild:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
inline_response_default:
|
||||
example:
|
||||
string:
|
||||
|
@ -0,0 +1,66 @@
|
||||
# NullableAllOf
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Child** | Pointer to [**NullableNullableAllOfChild**](NullableAllOfChild.md) | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewNullableAllOf
|
||||
|
||||
`func NewNullableAllOf() *NullableAllOf`
|
||||
|
||||
NewNullableAllOf instantiates a new NullableAllOf 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
|
||||
|
||||
### NewNullableAllOfWithDefaults
|
||||
|
||||
`func NewNullableAllOfWithDefaults() *NullableAllOf`
|
||||
|
||||
NewNullableAllOfWithDefaults instantiates a new NullableAllOf 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
|
||||
|
||||
### GetChild
|
||||
|
||||
`func (o *NullableAllOf) GetChild() NullableAllOfChild`
|
||||
|
||||
GetChild returns the Child field if non-nil, zero value otherwise.
|
||||
|
||||
### GetChildOk
|
||||
|
||||
`func (o *NullableAllOf) GetChildOk() (*NullableAllOfChild, bool)`
|
||||
|
||||
GetChildOk returns a tuple with the Child field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetChild
|
||||
|
||||
`func (o *NullableAllOf) SetChild(v NullableAllOfChild)`
|
||||
|
||||
SetChild sets Child field to given value.
|
||||
|
||||
### HasChild
|
||||
|
||||
`func (o *NullableAllOf) HasChild() bool`
|
||||
|
||||
HasChild returns a boolean if a field has been set.
|
||||
|
||||
### SetChildNil
|
||||
|
||||
`func (o *NullableAllOf) SetChildNil(b bool)`
|
||||
|
||||
SetChildNil sets the value for Child to be an explicit nil
|
||||
|
||||
### UnsetChild
|
||||
`func (o *NullableAllOf) UnsetChild()`
|
||||
|
||||
UnsetChild ensures that no value is present for Child, not even an explicit nil
|
||||
|
||||
[[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,56 @@
|
||||
# NullableAllOfChild
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | Pointer to **string** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewNullableAllOfChild
|
||||
|
||||
`func NewNullableAllOfChild() *NullableAllOfChild`
|
||||
|
||||
NewNullableAllOfChild instantiates a new NullableAllOfChild 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
|
||||
|
||||
### NewNullableAllOfChildWithDefaults
|
||||
|
||||
`func NewNullableAllOfChildWithDefaults() *NullableAllOfChild`
|
||||
|
||||
NewNullableAllOfChildWithDefaults instantiates a new NullableAllOfChild 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
|
||||
|
||||
### GetName
|
||||
|
||||
`func (o *NullableAllOfChild) GetName() string`
|
||||
|
||||
GetName returns the Name field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNameOk
|
||||
|
||||
`func (o *NullableAllOfChild) GetNameOk() (*string, bool)`
|
||||
|
||||
GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetName
|
||||
|
||||
`func (o *NullableAllOfChild) SetName(v string)`
|
||||
|
||||
SetName sets Name field to given value.
|
||||
|
||||
### HasName
|
||||
|
||||
`func (o *NullableAllOfChild) HasName() bool`
|
||||
|
||||
HasName returns a boolean if a field has been 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,56 @@
|
||||
# OneOfPrimitiveType
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | Pointer to **string** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewOneOfPrimitiveType
|
||||
|
||||
`func NewOneOfPrimitiveType() *OneOfPrimitiveType`
|
||||
|
||||
NewOneOfPrimitiveType instantiates a new OneOfPrimitiveType 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
|
||||
|
||||
### NewOneOfPrimitiveTypeWithDefaults
|
||||
|
||||
`func NewOneOfPrimitiveTypeWithDefaults() *OneOfPrimitiveType`
|
||||
|
||||
NewOneOfPrimitiveTypeWithDefaults instantiates a new OneOfPrimitiveType 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
|
||||
|
||||
### GetName
|
||||
|
||||
`func (o *OneOfPrimitiveType) GetName() string`
|
||||
|
||||
GetName returns the Name field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNameOk
|
||||
|
||||
`func (o *OneOfPrimitiveType) GetNameOk() (*string, bool)`
|
||||
|
||||
GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetName
|
||||
|
||||
`func (o *OneOfPrimitiveType) SetName(v string)`
|
||||
|
||||
SetName sets Name field to given value.
|
||||
|
||||
### HasName
|
||||
|
||||
`func (o *OneOfPrimitiveType) HasName() bool`
|
||||
|
||||
HasName returns a boolean if a field has been 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,56 @@
|
||||
# OneOfPrimitiveTypeChild
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | Pointer to **string** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewOneOfPrimitiveTypeChild
|
||||
|
||||
`func NewOneOfPrimitiveTypeChild() *OneOfPrimitiveTypeChild`
|
||||
|
||||
NewOneOfPrimitiveTypeChild instantiates a new OneOfPrimitiveTypeChild 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
|
||||
|
||||
### NewOneOfPrimitiveTypeChildWithDefaults
|
||||
|
||||
`func NewOneOfPrimitiveTypeChildWithDefaults() *OneOfPrimitiveTypeChild`
|
||||
|
||||
NewOneOfPrimitiveTypeChildWithDefaults instantiates a new OneOfPrimitiveTypeChild 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
|
||||
|
||||
### GetName
|
||||
|
||||
`func (o *OneOfPrimitiveTypeChild) GetName() string`
|
||||
|
||||
GetName returns the Name field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNameOk
|
||||
|
||||
`func (o *OneOfPrimitiveTypeChild) GetNameOk() (*string, bool)`
|
||||
|
||||
GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetName
|
||||
|
||||
`func (o *OneOfPrimitiveTypeChild) SetName(v string)`
|
||||
|
||||
SetName sets Name field to given value.
|
||||
|
||||
### HasName
|
||||
|
||||
`func (o *OneOfPrimitiveTypeChild) HasName() bool`
|
||||
|
||||
HasName returns a boolean if a field has been 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,150 @@
|
||||
/*
|
||||
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"
|
||||
)
|
||||
|
||||
// NullableAllOf struct for NullableAllOf
|
||||
type NullableAllOf struct {
|
||||
Child NullableNullableAllOfChild `json:"child,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
type _NullableAllOf NullableAllOf
|
||||
|
||||
// NewNullableAllOf instantiates a new NullableAllOf 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
|
||||
func NewNullableAllOf() *NullableAllOf {
|
||||
this := NullableAllOf{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewNullableAllOfWithDefaults instantiates a new NullableAllOf 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
|
||||
func NewNullableAllOfWithDefaults() *NullableAllOf {
|
||||
this := NullableAllOf{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetChild returns the Child field value if set, zero value otherwise (both if not set or set to explicit null).
|
||||
func (o *NullableAllOf) GetChild() NullableAllOfChild {
|
||||
if o == nil || o.Child.Get() == nil {
|
||||
var ret NullableAllOfChild
|
||||
return ret
|
||||
}
|
||||
return *o.Child.Get()
|
||||
}
|
||||
|
||||
// GetChildOk returns a tuple with the Child field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||
func (o *NullableAllOf) GetChildOk() (*NullableAllOfChild, bool) {
|
||||
if o == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.Child.Get(), o.Child.IsSet()
|
||||
}
|
||||
|
||||
// HasChild returns a boolean if a field has been set.
|
||||
func (o *NullableAllOf) HasChild() bool {
|
||||
if o != nil && o.Child.IsSet() {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetChild gets a reference to the given NullableNullableAllOfChild and assigns it to the Child field.
|
||||
func (o *NullableAllOf) SetChild(v NullableAllOfChild) {
|
||||
o.Child.Set(&v)
|
||||
}
|
||||
// SetChildNil sets the value for Child to be an explicit nil
|
||||
func (o *NullableAllOf) SetChildNil() {
|
||||
o.Child.Set(nil)
|
||||
}
|
||||
|
||||
// UnsetChild ensures that no value is present for Child, not even an explicit nil
|
||||
func (o *NullableAllOf) UnsetChild() {
|
||||
o.Child.Unset()
|
||||
}
|
||||
|
||||
func (o NullableAllOf) MarshalJSON() ([]byte, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if o.Child.IsSet() {
|
||||
toSerialize["child"] = o.Child.Get()
|
||||
}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o *NullableAllOf) UnmarshalJSON(bytes []byte) (err error) {
|
||||
varNullableAllOf := _NullableAllOf{}
|
||||
|
||||
if err = json.Unmarshal(bytes, &varNullableAllOf); err == nil {
|
||||
*o = NullableAllOf(varNullableAllOf)
|
||||
}
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||
delete(additionalProperties, "child")
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type NullableNullableAllOf struct {
|
||||
value *NullableAllOf
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableNullableAllOf) Get() *NullableAllOf {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableNullableAllOf) Set(val *NullableAllOf) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableNullableAllOf) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableNullableAllOf) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableNullableAllOf(val *NullableAllOf) *NullableNullableAllOf {
|
||||
return &NullableNullableAllOf{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableNullableAllOf) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableNullableAllOf) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
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"
|
||||
)
|
||||
|
||||
// NullableAllOfChild struct for NullableAllOfChild
|
||||
type NullableAllOfChild struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
type _NullableAllOfChild NullableAllOfChild
|
||||
|
||||
// NewNullableAllOfChild instantiates a new NullableAllOfChild 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
|
||||
func NewNullableAllOfChild() *NullableAllOfChild {
|
||||
this := NullableAllOfChild{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewNullableAllOfChildWithDefaults instantiates a new NullableAllOfChild 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
|
||||
func NewNullableAllOfChildWithDefaults() *NullableAllOfChild {
|
||||
this := NullableAllOfChild{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetName returns the Name field value if set, zero value otherwise.
|
||||
func (o *NullableAllOfChild) GetName() string {
|
||||
if o == nil || o.Name == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Name
|
||||
}
|
||||
|
||||
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *NullableAllOfChild) GetNameOk() (*string, bool) {
|
||||
if o == nil || o.Name == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.Name, true
|
||||
}
|
||||
|
||||
// HasName returns a boolean if a field has been set.
|
||||
func (o *NullableAllOfChild) HasName() bool {
|
||||
if o != nil && o.Name != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetName gets a reference to the given string and assigns it to the Name field.
|
||||
func (o *NullableAllOfChild) SetName(v string) {
|
||||
o.Name = &v
|
||||
}
|
||||
|
||||
func (o NullableAllOfChild) MarshalJSON() ([]byte, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if o.Name != nil {
|
||||
toSerialize["name"] = o.Name
|
||||
}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o *NullableAllOfChild) UnmarshalJSON(bytes []byte) (err error) {
|
||||
varNullableAllOfChild := _NullableAllOfChild{}
|
||||
|
||||
if err = json.Unmarshal(bytes, &varNullableAllOfChild); err == nil {
|
||||
*o = NullableAllOfChild(varNullableAllOfChild)
|
||||
}
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||
delete(additionalProperties, "name")
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type NullableNullableAllOfChild struct {
|
||||
value *NullableAllOfChild
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableNullableAllOfChild) Get() *NullableAllOfChild {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableNullableAllOfChild) Set(val *NullableAllOfChild) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableNullableAllOfChild) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableNullableAllOfChild) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableNullableAllOfChild(val *NullableAllOfChild) *NullableNullableAllOfChild {
|
||||
return &NullableNullableAllOfChild{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableNullableAllOfChild) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableNullableAllOfChild) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,148 @@
|
||||
/*
|
||||
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"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// OneOfPrimitiveType - struct for OneOfPrimitiveType
|
||||
type OneOfPrimitiveType struct {
|
||||
OneOfPrimitiveTypeChild *OneOfPrimitiveTypeChild
|
||||
Int32 *int32
|
||||
}
|
||||
|
||||
// OneOfPrimitiveTypeChildAsOneOfPrimitiveType is a convenience function that returns OneOfPrimitiveTypeChild wrapped in OneOfPrimitiveType
|
||||
func OneOfPrimitiveTypeChildAsOneOfPrimitiveType(v *OneOfPrimitiveTypeChild) OneOfPrimitiveType {
|
||||
return OneOfPrimitiveType{
|
||||
OneOfPrimitiveTypeChild: v,
|
||||
}
|
||||
}
|
||||
|
||||
// int32AsOneOfPrimitiveType is a convenience function that returns int32 wrapped in OneOfPrimitiveType
|
||||
func Int32AsOneOfPrimitiveType(v *int32) OneOfPrimitiveType {
|
||||
return OneOfPrimitiveType{
|
||||
Int32: v,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Unmarshal JSON data into one of the pointers in the struct
|
||||
func (dst *OneOfPrimitiveType) UnmarshalJSON(data []byte) error {
|
||||
var err error
|
||||
match := 0
|
||||
// try to unmarshal data into OneOfPrimitiveTypeChild
|
||||
err = newStrictDecoder(data).Decode(&dst.OneOfPrimitiveTypeChild)
|
||||
if err == nil {
|
||||
jsonOneOfPrimitiveTypeChild, _ := json.Marshal(dst.OneOfPrimitiveTypeChild)
|
||||
if string(jsonOneOfPrimitiveTypeChild) == "{}" { // empty struct
|
||||
dst.OneOfPrimitiveTypeChild = nil
|
||||
} else {
|
||||
match++
|
||||
}
|
||||
} else {
|
||||
dst.OneOfPrimitiveTypeChild = nil
|
||||
}
|
||||
|
||||
// try to unmarshal data into Int32
|
||||
err = newStrictDecoder(data).Decode(&dst.Int32)
|
||||
if err == nil {
|
||||
jsonInt32, _ := json.Marshal(dst.Int32)
|
||||
if string(jsonInt32) == "{}" { // empty struct
|
||||
dst.Int32 = nil
|
||||
} else {
|
||||
match++
|
||||
}
|
||||
} else {
|
||||
dst.Int32 = nil
|
||||
}
|
||||
|
||||
if match > 1 { // more than 1 match
|
||||
// reset to nil
|
||||
dst.OneOfPrimitiveTypeChild = nil
|
||||
dst.Int32 = nil
|
||||
|
||||
return fmt.Errorf("Data matches more than one schema in oneOf(OneOfPrimitiveType)")
|
||||
} else if match == 1 {
|
||||
return nil // exactly one match
|
||||
} else { // no match
|
||||
return fmt.Errorf("Data failed to match schemas in oneOf(OneOfPrimitiveType)")
|
||||
}
|
||||
}
|
||||
|
||||
// Marshal data from the first non-nil pointers in the struct to JSON
|
||||
func (src OneOfPrimitiveType) MarshalJSON() ([]byte, error) {
|
||||
if src.OneOfPrimitiveTypeChild != nil {
|
||||
return json.Marshal(&src.OneOfPrimitiveTypeChild)
|
||||
}
|
||||
|
||||
if src.Int32 != nil {
|
||||
return json.Marshal(&src.Int32)
|
||||
}
|
||||
|
||||
return nil, nil // no data in oneOf schemas
|
||||
}
|
||||
|
||||
// Get the actual instance
|
||||
func (obj *OneOfPrimitiveType) GetActualInstance() (interface{}) {
|
||||
if obj == nil {
|
||||
return nil
|
||||
}
|
||||
if obj.OneOfPrimitiveTypeChild != nil {
|
||||
return obj.OneOfPrimitiveTypeChild
|
||||
}
|
||||
|
||||
if obj.Int32 != nil {
|
||||
return obj.Int32
|
||||
}
|
||||
|
||||
// all schemas are nil
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullableOneOfPrimitiveType struct {
|
||||
value *OneOfPrimitiveType
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableOneOfPrimitiveType) Get() *OneOfPrimitiveType {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableOneOfPrimitiveType) Set(val *OneOfPrimitiveType) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableOneOfPrimitiveType) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableOneOfPrimitiveType) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableOneOfPrimitiveType(val *OneOfPrimitiveType) *NullableOneOfPrimitiveType {
|
||||
return &NullableOneOfPrimitiveType{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableOneOfPrimitiveType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableOneOfPrimitiveType) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
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"
|
||||
)
|
||||
|
||||
// OneOfPrimitiveTypeChild struct for OneOfPrimitiveTypeChild
|
||||
type OneOfPrimitiveTypeChild struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
type _OneOfPrimitiveTypeChild OneOfPrimitiveTypeChild
|
||||
|
||||
// NewOneOfPrimitiveTypeChild instantiates a new OneOfPrimitiveTypeChild 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
|
||||
func NewOneOfPrimitiveTypeChild() *OneOfPrimitiveTypeChild {
|
||||
this := OneOfPrimitiveTypeChild{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewOneOfPrimitiveTypeChildWithDefaults instantiates a new OneOfPrimitiveTypeChild 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
|
||||
func NewOneOfPrimitiveTypeChildWithDefaults() *OneOfPrimitiveTypeChild {
|
||||
this := OneOfPrimitiveTypeChild{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetName returns the Name field value if set, zero value otherwise.
|
||||
func (o *OneOfPrimitiveTypeChild) GetName() string {
|
||||
if o == nil || o.Name == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Name
|
||||
}
|
||||
|
||||
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *OneOfPrimitiveTypeChild) GetNameOk() (*string, bool) {
|
||||
if o == nil || o.Name == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.Name, true
|
||||
}
|
||||
|
||||
// HasName returns a boolean if a field has been set.
|
||||
func (o *OneOfPrimitiveTypeChild) HasName() bool {
|
||||
if o != nil && o.Name != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetName gets a reference to the given string and assigns it to the Name field.
|
||||
func (o *OneOfPrimitiveTypeChild) SetName(v string) {
|
||||
o.Name = &v
|
||||
}
|
||||
|
||||
func (o OneOfPrimitiveTypeChild) MarshalJSON() ([]byte, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if o.Name != nil {
|
||||
toSerialize["name"] = o.Name
|
||||
}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o *OneOfPrimitiveTypeChild) UnmarshalJSON(bytes []byte) (err error) {
|
||||
varOneOfPrimitiveTypeChild := _OneOfPrimitiveTypeChild{}
|
||||
|
||||
if err = json.Unmarshal(bytes, &varOneOfPrimitiveTypeChild); err == nil {
|
||||
*o = OneOfPrimitiveTypeChild(varOneOfPrimitiveTypeChild)
|
||||
}
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||
delete(additionalProperties, "name")
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type NullableOneOfPrimitiveTypeChild struct {
|
||||
value *OneOfPrimitiveTypeChild
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableOneOfPrimitiveTypeChild) Get() *OneOfPrimitiveTypeChild {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableOneOfPrimitiveTypeChild) Set(val *OneOfPrimitiveTypeChild) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableOneOfPrimitiveTypeChild) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableOneOfPrimitiveTypeChild) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableOneOfPrimitiveTypeChild(val *OneOfPrimitiveTypeChild) *NullableOneOfPrimitiveTypeChild {
|
||||
return &NullableOneOfPrimitiveTypeChild{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableOneOfPrimitiveTypeChild) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableOneOfPrimitiveTypeChild) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
@ -7,5 +7,6 @@ replace go-petstore => ./go-petstore
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go-petstore v0.0.0-00010101000000-000000000000
|
||||
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
|
||||
)
|
||||
|
@ -184,6 +184,10 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
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-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -191,6 +195,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 h1:D7nTwh4J0i+5mW4Zjzn5omvlr6YBcWywE6KOcatyNxY=
|
||||
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a h1:qfl7ob3DIEs3Ml9oLuPwY2N04gymzAW04WsUQHIClgM=
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||
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-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -224,11 +230,15 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
Loading…
x
Reference in New Issue
Block a user