mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
[Go] Fix an issue causing int array reference translated to an invalid type []Integer (#19013)
* [Go] Fix an issue causing int array ref be converted into an invalid type, `[]Integer` * Add test case: wrapped and referenced integer of an array to Go client samples * add check for ref to property in go abstract * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java Co-authored-by: Zhiwei <zhiwei.liang27@pm.me> --------- Co-authored-by: Zhiwei Liang <zhi.wei.liang@outlook.com> Co-authored-by: Zhiwei <zhiwei.liang27@pm.me>
This commit is contained in:
parent
ba9ac74237
commit
6aa825bcf7
@ -40,17 +40,27 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(AbstractGoCodegen.class);
|
||||
private static final String NUMERIC_ENUM_PREFIX = "_";
|
||||
|
||||
@Setter protected boolean withGoCodegenComment = false;
|
||||
@Setter protected boolean withAWSV4Signature = false;
|
||||
@Setter protected boolean withXml = false;
|
||||
@Setter protected boolean enumClassPrefix = false;
|
||||
@Setter protected boolean structPrefix = false;
|
||||
@Setter protected boolean generateInterfaces = false;
|
||||
@Setter protected boolean withGoMod = false;
|
||||
@Setter protected boolean generateMarshalJSON = true;
|
||||
@Setter protected boolean generateUnmarshalJSON = true;
|
||||
@Setter
|
||||
protected boolean withGoCodegenComment = false;
|
||||
@Setter
|
||||
protected boolean withAWSV4Signature = false;
|
||||
@Setter
|
||||
protected boolean withXml = false;
|
||||
@Setter
|
||||
protected boolean enumClassPrefix = false;
|
||||
@Setter
|
||||
protected boolean structPrefix = false;
|
||||
@Setter
|
||||
protected boolean generateInterfaces = false;
|
||||
@Setter
|
||||
protected boolean withGoMod = false;
|
||||
@Setter
|
||||
protected boolean generateMarshalJSON = true;
|
||||
@Setter
|
||||
protected boolean generateUnmarshalJSON = true;
|
||||
|
||||
@Setter protected String packageName = "openapi";
|
||||
@Setter
|
||||
protected String packageName = "openapi";
|
||||
protected Set<String> numberTypes;
|
||||
|
||||
public AbstractGoCodegen() {
|
||||
@ -424,6 +434,13 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
String ref = p.get$ref();
|
||||
String type;
|
||||
|
||||
// schema is a ref to property's schema e.g. #/components/schemas/Pet/properties/id
|
||||
if (ModelUtils.isRefToSchemaWithProperties(ref)) {
|
||||
Schema propertySchema = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, ref);
|
||||
openAPIType = super.getSchemaType(propertySchema);
|
||||
ref = propertySchema.get$ref();
|
||||
}
|
||||
|
||||
if (ref != null && !ref.isEmpty()) {
|
||||
type = toModelName(openAPIType);
|
||||
} else if ("object".equals(openAPIType) && ModelUtils.isAnyType(p)) {
|
||||
@ -431,10 +448,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
type = "interface{}";
|
||||
} else if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return (type);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
type = openAPIType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -753,7 +772,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
imports.add(createMapping("import", "time"));
|
||||
addedTimeImport = true;
|
||||
}
|
||||
|
||||
|
||||
if (!addedOSImport && ("*os.File".equals(cp.dataType) ||
|
||||
(cp.items != null && "*os.File".equals(cp.items.dataType)))) {
|
||||
imports.add(createMapping("import", "os"));
|
||||
@ -762,15 +781,15 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
if (cp.pattern != null) {
|
||||
cp.vendorExtensions.put("x-go-custom-tag", "validate:\"regexp=" +
|
||||
cp.pattern.replace("\\","\\\\").replaceAll("^/|/$","") +
|
||||
"\"");
|
||||
cp.pattern.replace("\\", "\\\\").replaceAll("^/|/$", "") +
|
||||
"\"");
|
||||
}
|
||||
}
|
||||
if (this instanceof GoClientCodegen && model.isEnum) {
|
||||
imports.add(createMapping("import", "fmt"));
|
||||
}
|
||||
|
||||
if(model.oneOf != null && !model.oneOf.isEmpty() && !addedValidator && generateUnmarshalJSON) {
|
||||
if (model.oneOf != null && !model.oneOf.isEmpty() && !addedValidator && generateUnmarshalJSON) {
|
||||
imports.add(createMapping("import", "gopkg.in/validator.v2"));
|
||||
addedValidator = true;
|
||||
}
|
||||
|
@ -1268,6 +1268,29 @@ paths:
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
/fake/wrapped-integer-ref:
|
||||
post:
|
||||
operationId: someOpsRequiringRefInt
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- ids
|
||||
properties:
|
||||
MyIDs:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/IDsWrapper/properties/id'
|
||||
responses:
|
||||
'200':
|
||||
description: success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
servers:
|
||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||
description: petstore server
|
||||
@ -2191,3 +2214,8 @@ components:
|
||||
type: object
|
||||
- type: object
|
||||
- type: "null"
|
||||
IDsWrapper:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
|
@ -48,6 +48,7 @@ docs/FruitReq.md
|
||||
docs/GmFruit.md
|
||||
docs/HasOnlyReadOnly.md
|
||||
docs/HealthCheckResult.md
|
||||
docs/IDsWrapper.md
|
||||
docs/IncidentData.md
|
||||
docs/List.md
|
||||
docs/Mammal.md
|
||||
@ -75,6 +76,7 @@ docs/PropertyNameMapping.md
|
||||
docs/ReadOnlyFirst.md
|
||||
docs/ReadOnlyWithDefault.md
|
||||
docs/Return.md
|
||||
docs/SomeOpsRequiringRefIntRequest.md
|
||||
docs/SpecialModelName.md
|
||||
docs/StoreAPI.md
|
||||
docs/Tag.md
|
||||
@ -121,6 +123,7 @@ model_fruit_req.go
|
||||
model_gm_fruit.go
|
||||
model_has_only_read_only.go
|
||||
model_health_check_result.go
|
||||
model_ids_wrapper.go
|
||||
model_incident_data.go
|
||||
model_list.go
|
||||
model_mammal.go
|
||||
@ -146,6 +149,7 @@ model_property_name_mapping.go
|
||||
model_read_only_first.go
|
||||
model_read_only_with_default.go
|
||||
model_return.go
|
||||
model_some_ops_requiring_ref_int_request.go
|
||||
model_tag.go
|
||||
model_test_inline_freeform_additional_properties_request.go
|
||||
model_user.go
|
||||
|
@ -81,6 +81,7 @@ Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeAPI* | [**Call123TestSpecialTags**](docs/AnotherFakeAPI.md#call123testspecialtags) | **Patch** /another-fake/dummy | To test special tags
|
||||
*DefaultAPI* | [**FooGet**](docs/DefaultAPI.md#fooget) | **Get** /foo |
|
||||
*DefaultAPI* | [**SomeOpsRequiringRefInt**](docs/DefaultAPI.md#someopsrequiringrefint) | **Post** /fake/wrapped-integer-ref |
|
||||
*FakeAPI* | [**FakeHealthGet**](docs/FakeAPI.md#fakehealthget) | **Get** /fake/health | Health check endpoint
|
||||
*FakeAPI* | [**FakeOuterBooleanSerialize**](docs/FakeAPI.md#fakeouterbooleanserialize) | **Post** /fake/outer/boolean |
|
||||
*FakeAPI* | [**FakeOuterCompositeSerialize**](docs/FakeAPI.md#fakeoutercompositeserialize) | **Post** /fake/outer/composite |
|
||||
@ -160,6 +161,7 @@ Class | Method | HTTP request | Description
|
||||
- [GmFruit](docs/GmFruit.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||
- [IDsWrapper](docs/IDsWrapper.md)
|
||||
- [IncidentData](docs/IncidentData.md)
|
||||
- [List](docs/List.md)
|
||||
- [Mammal](docs/Mammal.md)
|
||||
@ -186,6 +188,7 @@ Class | Method | HTTP request | Description
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [ReadOnlyWithDefault](docs/ReadOnlyWithDefault.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [SomeOpsRequiringRefIntRequest](docs/SomeOpsRequiringRefIntRequest.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
|
||||
|
@ -1233,6 +1233,22 @@ paths:
|
||||
summary: parameter name mapping test
|
||||
tags:
|
||||
- fake
|
||||
/fake/wrapped-integer-ref:
|
||||
post:
|
||||
operationId: someOpsRequiringRefInt
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/someOpsRequiringRefInt_request'
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
description: success
|
||||
components:
|
||||
requestBodies:
|
||||
UserArray:
|
||||
@ -2177,6 +2193,11 @@ components:
|
||||
type: object
|
||||
type: array
|
||||
- type: object
|
||||
IDsWrapper:
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
type: object
|
||||
_foo_get_default_response:
|
||||
example:
|
||||
string:
|
||||
@ -2330,6 +2351,15 @@ components:
|
||||
required:
|
||||
- requiredFile
|
||||
type: object
|
||||
someOpsRequiringRefInt_request:
|
||||
properties:
|
||||
MyIDs:
|
||||
items:
|
||||
$ref: '#/components/schemas/IDsWrapper/properties/id'
|
||||
type: array
|
||||
required:
|
||||
- ids
|
||||
type: object
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
flows:
|
||||
|
@ -32,6 +32,18 @@ type DefaultAPI interface {
|
||||
// FooGetExecute executes the request
|
||||
// @return FooGetDefaultResponse
|
||||
FooGetExecute(r ApiFooGetRequest) (*FooGetDefaultResponse, *http.Response, error)
|
||||
|
||||
/*
|
||||
SomeOpsRequiringRefInt Method for SomeOpsRequiringRefInt
|
||||
|
||||
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@return ApiSomeOpsRequiringRefIntRequest
|
||||
*/
|
||||
SomeOpsRequiringRefInt(ctx context.Context) ApiSomeOpsRequiringRefIntRequest
|
||||
|
||||
// SomeOpsRequiringRefIntExecute executes the request
|
||||
// @return map[string]interface{}
|
||||
SomeOpsRequiringRefIntExecute(r ApiSomeOpsRequiringRefIntRequest) (map[string]interface{}, *http.Response, error)
|
||||
}
|
||||
|
||||
// DefaultAPIService DefaultAPI service
|
||||
@ -163,3 +175,111 @@ func (a *DefaultAPIService) FooGetExecute(r ApiFooGetRequest) (*FooGetDefaultRes
|
||||
|
||||
return localVarReturnValue, localVarHTTPResponse, nil
|
||||
}
|
||||
|
||||
type ApiSomeOpsRequiringRefIntRequest struct {
|
||||
ctx context.Context
|
||||
ApiService DefaultAPI
|
||||
someOpsRequiringRefIntRequest *SomeOpsRequiringRefIntRequest
|
||||
}
|
||||
|
||||
func (r ApiSomeOpsRequiringRefIntRequest) SomeOpsRequiringRefIntRequest(someOpsRequiringRefIntRequest SomeOpsRequiringRefIntRequest) ApiSomeOpsRequiringRefIntRequest {
|
||||
r.someOpsRequiringRefIntRequest = &someOpsRequiringRefIntRequest
|
||||
return r
|
||||
}
|
||||
|
||||
func (r ApiSomeOpsRequiringRefIntRequest) Execute() (map[string]interface{}, *http.Response, error) {
|
||||
return r.ApiService.SomeOpsRequiringRefIntExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
SomeOpsRequiringRefInt Method for SomeOpsRequiringRefInt
|
||||
|
||||
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@return ApiSomeOpsRequiringRefIntRequest
|
||||
*/
|
||||
func (a *DefaultAPIService) SomeOpsRequiringRefInt(ctx context.Context) ApiSomeOpsRequiringRefIntRequest {
|
||||
return ApiSomeOpsRequiringRefIntRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// Execute executes the request
|
||||
// @return map[string]interface{}
|
||||
func (a *DefaultAPIService) SomeOpsRequiringRefIntExecute(r ApiSomeOpsRequiringRefIntRequest) (map[string]interface{}, *http.Response, error) {
|
||||
var (
|
||||
localVarHTTPMethod = http.MethodPost
|
||||
localVarPostBody interface{}
|
||||
formFiles []formFile
|
||||
localVarReturnValue map[string]interface{}
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.SomeOpsRequiringRefInt")
|
||||
if err != nil {
|
||||
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/fake/wrapped-integer-ref"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
if r.someOpsRequiringRefIntRequest == nil {
|
||||
return localVarReturnValue, nil, reportError("someOpsRequiringRefIntRequest is required and must be specified")
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{"application/json"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{"application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = r.someOpsRequiringRefIntRequest
|
||||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
||||
if err != nil {
|
||||
return localVarReturnValue, nil, err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(req)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return localVarReturnValue, localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
||||
localVarHTTPResponse.Body.Close()
|
||||
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
||||
if err != nil {
|
||||
return localVarReturnValue, localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
newErr := &GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: localVarHTTPResponse.Status,
|
||||
}
|
||||
return localVarReturnValue, localVarHTTPResponse, newErr
|
||||
}
|
||||
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr := &GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: err.Error(),
|
||||
}
|
||||
return localVarReturnValue, localVarHTTPResponse, newErr
|
||||
}
|
||||
|
||||
return localVarReturnValue, localVarHTTPResponse, nil
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**FooGet**](DefaultAPI.md#FooGet) | **Get** /foo |
|
||||
[**SomeOpsRequiringRefInt**](DefaultAPI.md#SomeOpsRequiringRefInt) | **Post** /fake/wrapped-integer-ref |
|
||||
|
||||
|
||||
|
||||
@ -66,3 +67,67 @@ No authorization required
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SomeOpsRequiringRefInt
|
||||
|
||||
> map[string]interface{} SomeOpsRequiringRefInt(ctx).SomeOpsRequiringRefIntRequest(someOpsRequiringRefIntRequest).Execute()
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
someOpsRequiringRefIntRequest := *openapiclient.NewSomeOpsRequiringRefIntRequest() // SomeOpsRequiringRefIntRequest |
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.DefaultAPI.SomeOpsRequiringRefInt(context.Background()).SomeOpsRequiringRefIntRequest(someOpsRequiringRefIntRequest).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.SomeOpsRequiringRefInt``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SomeOpsRequiringRefInt`: map[string]interface{}
|
||||
fmt.Fprintf(os.Stdout, "Response from `DefaultAPI.SomeOpsRequiringRefInt`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSomeOpsRequiringRefIntRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**someOpsRequiringRefIntRequest** | [**SomeOpsRequiringRefIntRequest**](SomeOpsRequiringRefIntRequest.md) | |
|
||||
|
||||
### Return type
|
||||
|
||||
**map[string]interface{}**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
# IDsWrapper
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id** | Pointer to **int32** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewIDsWrapper
|
||||
|
||||
`func NewIDsWrapper() *IDsWrapper`
|
||||
|
||||
NewIDsWrapper instantiates a new IDsWrapper 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
|
||||
|
||||
### NewIDsWrapperWithDefaults
|
||||
|
||||
`func NewIDsWrapperWithDefaults() *IDsWrapper`
|
||||
|
||||
NewIDsWrapperWithDefaults instantiates a new IDsWrapper 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
|
||||
|
||||
### GetId
|
||||
|
||||
`func (o *IDsWrapper) GetId() int32`
|
||||
|
||||
GetId returns the Id field if non-nil, zero value otherwise.
|
||||
|
||||
### GetIdOk
|
||||
|
||||
`func (o *IDsWrapper) GetIdOk() (*int32, bool)`
|
||||
|
||||
GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetId
|
||||
|
||||
`func (o *IDsWrapper) SetId(v int32)`
|
||||
|
||||
SetId sets Id field to given value.
|
||||
|
||||
### HasId
|
||||
|
||||
`func (o *IDsWrapper) HasId() bool`
|
||||
|
||||
HasId 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 @@
|
||||
# SomeOpsRequiringRefIntRequest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**MyIDs** | Pointer to **[]int32** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewSomeOpsRequiringRefIntRequest
|
||||
|
||||
`func NewSomeOpsRequiringRefIntRequest() *SomeOpsRequiringRefIntRequest`
|
||||
|
||||
NewSomeOpsRequiringRefIntRequest instantiates a new SomeOpsRequiringRefIntRequest 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
|
||||
|
||||
### NewSomeOpsRequiringRefIntRequestWithDefaults
|
||||
|
||||
`func NewSomeOpsRequiringRefIntRequestWithDefaults() *SomeOpsRequiringRefIntRequest`
|
||||
|
||||
NewSomeOpsRequiringRefIntRequestWithDefaults instantiates a new SomeOpsRequiringRefIntRequest 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
|
||||
|
||||
### GetMyIDs
|
||||
|
||||
`func (o *SomeOpsRequiringRefIntRequest) GetMyIDs() []int32`
|
||||
|
||||
GetMyIDs returns the MyIDs field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMyIDsOk
|
||||
|
||||
`func (o *SomeOpsRequiringRefIntRequest) GetMyIDsOk() (*[]int32, bool)`
|
||||
|
||||
GetMyIDsOk returns a tuple with the MyIDs field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMyIDs
|
||||
|
||||
`func (o *SomeOpsRequiringRefIntRequest) SetMyIDs(v []int32)`
|
||||
|
||||
SetMyIDs sets MyIDs field to given value.
|
||||
|
||||
### HasMyIDs
|
||||
|
||||
`func (o *SomeOpsRequiringRefIntRequest) HasMyIDs() bool`
|
||||
|
||||
HasMyIDs 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,155 @@
|
||||
/*
|
||||
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"
|
||||
)
|
||||
|
||||
// checks if the IDsWrapper type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &IDsWrapper{}
|
||||
|
||||
// IDsWrapper struct for IDsWrapper
|
||||
type IDsWrapper struct {
|
||||
Id *int32 `json:"id,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
type _IDsWrapper IDsWrapper
|
||||
|
||||
// NewIDsWrapper instantiates a new IDsWrapper 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 NewIDsWrapper() *IDsWrapper {
|
||||
this := IDsWrapper{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewIDsWrapperWithDefaults instantiates a new IDsWrapper 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 NewIDsWrapperWithDefaults() *IDsWrapper {
|
||||
this := IDsWrapper{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetId returns the Id field value if set, zero value otherwise.
|
||||
func (o *IDsWrapper) GetId() int32 {
|
||||
if o == nil || IsNil(o.Id) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.Id
|
||||
}
|
||||
|
||||
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *IDsWrapper) GetIdOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.Id) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Id, true
|
||||
}
|
||||
|
||||
// HasId returns a boolean if a field has been set.
|
||||
func (o *IDsWrapper) HasId() bool {
|
||||
if o != nil && !IsNil(o.Id) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetId gets a reference to the given int32 and assigns it to the Id field.
|
||||
func (o *IDsWrapper) SetId(v int32) {
|
||||
o.Id = &v
|
||||
}
|
||||
|
||||
func (o IDsWrapper) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o IDsWrapper) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Id) {
|
||||
toSerialize["id"] = o.Id
|
||||
}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
func (o *IDsWrapper) UnmarshalJSON(data []byte) (err error) {
|
||||
varIDsWrapper := _IDsWrapper{}
|
||||
|
||||
err = json.Unmarshal(data, &varIDsWrapper)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*o = IDsWrapper(varIDsWrapper)
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(data, &additionalProperties); err == nil {
|
||||
delete(additionalProperties, "id")
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type NullableIDsWrapper struct {
|
||||
value *IDsWrapper
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableIDsWrapper) Get() *IDsWrapper {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableIDsWrapper) Set(val *IDsWrapper) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableIDsWrapper) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableIDsWrapper) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableIDsWrapper(val *IDsWrapper) *NullableIDsWrapper {
|
||||
return &NullableIDsWrapper{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableIDsWrapper) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableIDsWrapper) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,155 @@
|
||||
/*
|
||||
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"
|
||||
)
|
||||
|
||||
// checks if the SomeOpsRequiringRefIntRequest type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &SomeOpsRequiringRefIntRequest{}
|
||||
|
||||
// SomeOpsRequiringRefIntRequest struct for SomeOpsRequiringRefIntRequest
|
||||
type SomeOpsRequiringRefIntRequest struct {
|
||||
MyIDs []int32 `json:"MyIDs,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
type _SomeOpsRequiringRefIntRequest SomeOpsRequiringRefIntRequest
|
||||
|
||||
// NewSomeOpsRequiringRefIntRequest instantiates a new SomeOpsRequiringRefIntRequest 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 NewSomeOpsRequiringRefIntRequest() *SomeOpsRequiringRefIntRequest {
|
||||
this := SomeOpsRequiringRefIntRequest{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewSomeOpsRequiringRefIntRequestWithDefaults instantiates a new SomeOpsRequiringRefIntRequest 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 NewSomeOpsRequiringRefIntRequestWithDefaults() *SomeOpsRequiringRefIntRequest {
|
||||
this := SomeOpsRequiringRefIntRequest{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetMyIDs returns the MyIDs field value if set, zero value otherwise.
|
||||
func (o *SomeOpsRequiringRefIntRequest) GetMyIDs() []int32 {
|
||||
if o == nil || IsNil(o.MyIDs) {
|
||||
var ret []int32
|
||||
return ret
|
||||
}
|
||||
return o.MyIDs
|
||||
}
|
||||
|
||||
// GetMyIDsOk returns a tuple with the MyIDs field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *SomeOpsRequiringRefIntRequest) GetMyIDsOk() ([]int32, bool) {
|
||||
if o == nil || IsNil(o.MyIDs) {
|
||||
return nil, false
|
||||
}
|
||||
return o.MyIDs, true
|
||||
}
|
||||
|
||||
// HasMyIDs returns a boolean if a field has been set.
|
||||
func (o *SomeOpsRequiringRefIntRequest) HasMyIDs() bool {
|
||||
if o != nil && !IsNil(o.MyIDs) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetMyIDs gets a reference to the given []int32 and assigns it to the MyIDs field.
|
||||
func (o *SomeOpsRequiringRefIntRequest) SetMyIDs(v []int32) {
|
||||
o.MyIDs = v
|
||||
}
|
||||
|
||||
func (o SomeOpsRequiringRefIntRequest) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o SomeOpsRequiringRefIntRequest) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.MyIDs) {
|
||||
toSerialize["MyIDs"] = o.MyIDs
|
||||
}
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
}
|
||||
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
func (o *SomeOpsRequiringRefIntRequest) UnmarshalJSON(data []byte) (err error) {
|
||||
varSomeOpsRequiringRefIntRequest := _SomeOpsRequiringRefIntRequest{}
|
||||
|
||||
err = json.Unmarshal(data, &varSomeOpsRequiringRefIntRequest)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*o = SomeOpsRequiringRefIntRequest(varSomeOpsRequiringRefIntRequest)
|
||||
|
||||
additionalProperties := make(map[string]interface{})
|
||||
|
||||
if err = json.Unmarshal(data, &additionalProperties); err == nil {
|
||||
delete(additionalProperties, "MyIDs")
|
||||
o.AdditionalProperties = additionalProperties
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type NullableSomeOpsRequiringRefIntRequest struct {
|
||||
value *SomeOpsRequiringRefIntRequest
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableSomeOpsRequiringRefIntRequest) Get() *SomeOpsRequiringRefIntRequest {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableSomeOpsRequiringRefIntRequest) Set(val *SomeOpsRequiringRefIntRequest) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableSomeOpsRequiringRefIntRequest) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableSomeOpsRequiringRefIntRequest) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableSomeOpsRequiringRefIntRequest(val *SomeOpsRequiringRefIntRequest) *NullableSomeOpsRequiringRefIntRequest {
|
||||
return &NullableSomeOpsRequiringRefIntRequest{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableSomeOpsRequiringRefIntRequest) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableSomeOpsRequiringRefIntRequest) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user