forked from loafle/openapi-generator-original
[Inline model resolver] better handling of inline responses and bug fixes (#12353)
* better handling of inline response schemas, bug fixes * update samples * add new files * better code format * remove unused ruby files * fix java test * remove unused js spec files * remove inline_response_default_test.dart * fix webclient tests * fix spring tests
This commit is contained in:
@@ -39,13 +39,13 @@ docs/FakeClassnameTags123Api.md
|
||||
docs/File.md
|
||||
docs/FileSchemaTestClass.md
|
||||
docs/Foo.md
|
||||
docs/FooGetDefaultResponse.md
|
||||
docs/FormatTest.md
|
||||
docs/Fruit.md
|
||||
docs/FruitReq.md
|
||||
docs/GmFruit.md
|
||||
docs/HasOnlyReadOnly.md
|
||||
docs/HealthCheckResult.md
|
||||
docs/InlineResponseDefault.md
|
||||
docs/List.md
|
||||
docs/Mammal.md
|
||||
docs/MapTest.md
|
||||
@@ -80,6 +80,7 @@ git_push.sh
|
||||
go.mod
|
||||
go.sum
|
||||
model_200_response.go
|
||||
model__foo_get_default_response.go
|
||||
model__special_model_name_.go
|
||||
model_additional_properties_class.go
|
||||
model_animal.go
|
||||
@@ -111,7 +112,6 @@ model_fruit_req.go
|
||||
model_gm_fruit.go
|
||||
model_has_only_read_only.go
|
||||
model_health_check_result.go
|
||||
model_inline_response_default.go
|
||||
model_list.go
|
||||
model_mammal.go
|
||||
model_map_test_.go
|
||||
|
||||
@@ -145,13 +145,13 @@ Class | Method | HTTP request | Description
|
||||
- [File](docs/File.md)
|
||||
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
|
||||
- [Foo](docs/Foo.md)
|
||||
- [FooGetDefaultResponse](docs/FooGetDefaultResponse.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
- [Fruit](docs/Fruit.md)
|
||||
- [FruitReq](docs/FruitReq.md)
|
||||
- [GmFruit](docs/GmFruit.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||
- [InlineResponseDefault](docs/InlineResponseDefault.md)
|
||||
- [List](docs/List.md)
|
||||
- [Mammal](docs/Mammal.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
|
||||
@@ -48,19 +48,19 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_response_default'
|
||||
$ref: '#/components/schemas/_foo_get_default_response'
|
||||
description: response
|
||||
"4XX":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_response_default'
|
||||
$ref: '#/components/schemas/_foo_get_default_response'
|
||||
description: client error
|
||||
"404":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_response_default'
|
||||
$ref: '#/components/schemas/_foo_get_default_response'
|
||||
description: not found
|
||||
/pet:
|
||||
post:
|
||||
@@ -1953,7 +1953,7 @@ components:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
inline_response_default:
|
||||
_foo_get_default_response:
|
||||
example:
|
||||
string:
|
||||
bar: bar
|
||||
|
||||
@@ -30,8 +30,8 @@ type DefaultApi interface {
|
||||
FooGet(ctx context.Context) ApiFooGetRequest
|
||||
|
||||
// FooGetExecute executes the request
|
||||
// @return InlineResponseDefault
|
||||
FooGetExecute(r ApiFooGetRequest) (*InlineResponseDefault, *http.Response, error)
|
||||
// @return FooGetDefaultResponse
|
||||
FooGetExecute(r ApiFooGetRequest) (*FooGetDefaultResponse, *http.Response, error)
|
||||
}
|
||||
|
||||
// DefaultApiService DefaultApi service
|
||||
@@ -42,7 +42,7 @@ type ApiFooGetRequest struct {
|
||||
ApiService DefaultApi
|
||||
}
|
||||
|
||||
func (r ApiFooGetRequest) Execute() (*InlineResponseDefault, *http.Response, error) {
|
||||
func (r ApiFooGetRequest) Execute() (*FooGetDefaultResponse, *http.Response, error) {
|
||||
return r.ApiService.FooGetExecute(r)
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ func (a *DefaultApiService) FooGet(ctx context.Context) ApiFooGetRequest {
|
||||
}
|
||||
|
||||
// Execute executes the request
|
||||
// @return InlineResponseDefault
|
||||
func (a *DefaultApiService) FooGetExecute(r ApiFooGetRequest) (*InlineResponseDefault, *http.Response, error) {
|
||||
// @return FooGetDefaultResponse
|
||||
func (a *DefaultApiService) FooGetExecute(r ApiFooGetRequest) (*FooGetDefaultResponse, *http.Response, error) {
|
||||
var (
|
||||
localVarHTTPMethod = http.MethodGet
|
||||
localVarPostBody interface{}
|
||||
formFiles []formFile
|
||||
localVarReturnValue *InlineResponseDefault
|
||||
localVarReturnValue *FooGetDefaultResponse
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.FooGet")
|
||||
@@ -120,7 +120,7 @@ func (a *DefaultApiService) FooGetExecute(r ApiFooGetRequest) (*InlineResponseDe
|
||||
error: localVarHTTPResponse.Status,
|
||||
}
|
||||
if localVarHTTPResponse.StatusCode == 404 {
|
||||
var v InlineResponseDefault
|
||||
var v FooGetDefaultResponse
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
@@ -130,7 +130,7 @@ func (a *DefaultApiService) FooGetExecute(r ApiFooGetRequest) (*InlineResponseDe
|
||||
return localVarReturnValue, localVarHTTPResponse, newErr
|
||||
}
|
||||
if localVarHTTPResponse.StatusCode >= 400 && localVarHTTPResponse.StatusCode < 500 {
|
||||
var v InlineResponseDefault
|
||||
var v FooGetDefaultResponse
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
@@ -139,7 +139,7 @@ func (a *DefaultApiService) FooGetExecute(r ApiFooGetRequest) (*InlineResponseDe
|
||||
newErr.model = v
|
||||
return localVarReturnValue, localVarHTTPResponse, newErr
|
||||
}
|
||||
var v InlineResponseDefault
|
||||
var v FooGetDefaultResponse
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
|
||||
@@ -10,7 +10,7 @@ Method | HTTP request | Description
|
||||
|
||||
## FooGet
|
||||
|
||||
> InlineResponseDefault FooGet(ctx).Execute()
|
||||
> FooGetDefaultResponse FooGet(ctx).Execute()
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.FooGet``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `FooGet`: InlineResponseDefault
|
||||
// response from `FooGet`: FooGetDefaultResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.FooGet`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
@@ -51,7 +51,7 @@ Other parameters are passed through a pointer to a apiFooGetRequest struct via t
|
||||
|
||||
### Return type
|
||||
|
||||
[**InlineResponseDefault**](InlineResponseDefault.md)
|
||||
[**FooGetDefaultResponse**](FooGetDefaultResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# FooGetDefaultResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**String** | Pointer to [**Foo**](Foo.md) | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewFooGetDefaultResponse
|
||||
|
||||
`func NewFooGetDefaultResponse() *FooGetDefaultResponse`
|
||||
|
||||
NewFooGetDefaultResponse instantiates a new FooGetDefaultResponse 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
|
||||
|
||||
### NewFooGetDefaultResponseWithDefaults
|
||||
|
||||
`func NewFooGetDefaultResponseWithDefaults() *FooGetDefaultResponse`
|
||||
|
||||
NewFooGetDefaultResponseWithDefaults instantiates a new FooGetDefaultResponse 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
|
||||
|
||||
### GetString
|
||||
|
||||
`func (o *FooGetDefaultResponse) GetString() Foo`
|
||||
|
||||
GetString returns the String field if non-nil, zero value otherwise.
|
||||
|
||||
### GetStringOk
|
||||
|
||||
`func (o *FooGetDefaultResponse) GetStringOk() (*Foo, bool)`
|
||||
|
||||
GetStringOk returns a tuple with the String field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetString
|
||||
|
||||
`func (o *FooGetDefaultResponse) SetString(v Foo)`
|
||||
|
||||
SetString sets String field to given value.
|
||||
|
||||
### HasString
|
||||
|
||||
`func (o *FooGetDefaultResponse) HasString() bool`
|
||||
|
||||
HasString 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,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"
|
||||
)
|
||||
|
||||
// FooGetDefaultResponse struct for FooGetDefaultResponse
|
||||
type FooGetDefaultResponse struct {
|
||||
String *Foo `json:"string,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
type _FooGetDefaultResponse FooGetDefaultResponse
|
||||
|
||||
// NewFooGetDefaultResponse instantiates a new FooGetDefaultResponse 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 NewFooGetDefaultResponse() *FooGetDefaultResponse {
|
||||
this := FooGetDefaultResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewFooGetDefaultResponseWithDefaults instantiates a new FooGetDefaultResponse 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 NewFooGetDefaultResponseWithDefaults() *FooGetDefaultResponse {
|
||||
this := FooGetDefaultResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetString returns the String field value if set, zero value otherwise.
|
||||
func (o *FooGetDefaultResponse) GetString() Foo {
|
||||
if o == nil || o.String == nil {
|
||||
var ret Foo
|
||||
return ret
|
||||
}
|
||||
return *o.String
|
||||
}
|
||||
|
||||
// GetStringOk returns a tuple with the String field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *FooGetDefaultResponse) GetStringOk() (*Foo, bool) {
|
||||
if o == nil || o.String == nil {
|
||||
return nil, false
|
||||
}
|
||||
return o.String, true
|
||||
}
|
||||
|
||||
// HasString returns a boolean if a field has been set.
|
||||
func (o *FooGetDefaultResponse) HasString() bool {
|
||||
if o != nil && o.String != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetString gets a reference to the given Foo and assigns it to the String field.
|
||||
func (o *FooGetDefaultResponse) SetString(v Foo) {
|
||||
o.String = &v
|
||||
}
|
||||
|
||||
func (o FooGetDefaultResponse) MarshalJSON() ([]byte, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if o.String != nil {
|
||||
toSerialize["string"] = o.String
|
||||
}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o *FooGetDefaultResponse) UnmarshalJSON(bytes []byte) (err error) {
|
||||
varFooGetDefaultResponse := _FooGetDefaultResponse{}
|
||||
|
||||
if err = json.Unmarshal(bytes, &varFooGetDefaultResponse); err == nil {
|
||||
*o = FooGetDefaultResponse(varFooGetDefaultResponse)
|
||||
}
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
|
||||
delete(additionalProperties, "string")
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type NullableFooGetDefaultResponse struct {
|
||||
value *FooGetDefaultResponse
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableFooGetDefaultResponse) Get() *FooGetDefaultResponse {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableFooGetDefaultResponse) Set(val *FooGetDefaultResponse) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableFooGetDefaultResponse) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableFooGetDefaultResponse) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableFooGetDefaultResponse(val *FooGetDefaultResponse) *NullableFooGetDefaultResponse {
|
||||
return &NullableFooGetDefaultResponse{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableFooGetDefaultResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableFooGetDefaultResponse) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user