Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6194093
fix undefined: localVarFile
grokify Jun 22, 2018
bf4aedb
add required formData file endpoints to 2.0 and 3.0 specs
grokify Jun 22, 2018
53caca1
streamline api.mustache update
grokify Jun 23, 2018
dc9c683
Merge branch 'master' into go-client/fix/formdata_required-file_undef…
grokify Jun 23, 2018
c7611aa
update sampels
grokify Jun 26, 2018
a543d57
update samples
grokify Jun 26, 2018
e6b0338
Merge branch 'master' into go-client/fix/formdata_required-file_undef…
grokify Jun 26, 2018
118404a
update samples
grokify Jun 26, 2018
5708f85
Merge branch 'master' into go-client/fix/formdata_required-file_undef…
grokify Jun 26, 2018
f72472d
update samples bin/jaxrs-cxf-client-petstore.sh
grokify Jun 26, 2018
10b9419
Merge branch 'master' into go-client/fix/testing
grokify Jun 26, 2018
87e240b
update samples
grokify Jun 26, 2018
3b15c3d
update samples
grokify Jun 27, 2018
2c6791c
update samples run-all-petstore
grokify Jun 27, 2018
61f76d9
Merge branch 'master' into go-client/fix/testing
grokify Jun 27, 2018
83874b1
update samples
grokify Jun 27, 2018
cf42bc8
update samples
grokify Jun 27, 2018
13fd826
update samples
grokify Jun 28, 2018
eb1e146
Trigger CI due to race condition
grokify Jun 28, 2018
89bfda5
merge master 9b909df543b8c541a17aa5a545473e6e511b140d
grokify Jun 28, 2018
2684c0c
update samples
grokify Jun 28, 2018
3439754
update samples
grokify Jun 28, 2018
f5cc397
Trigger CI due to previous timeout
grokify Jun 28, 2018
027091e
Trigger CI due to previous Shippable timeout
grokify Jun 28, 2018
e72745d
Trigger CI due to previous Shippable race condition
grokify Jun 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/openapi-generator/src/main/resources/go/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
{{#hasFormParams}}
{{#formParams}}
{{#isFile}}
{{#required}}
localVarFile := {{paramName}}
{{/required}}
{{^required}}
var localVarFile {{dataType}}
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,43 @@ paths:
- petstore_auth:
- 'write:pets'
- 'read:pets'
'/pet/{petId}/uploadImageWithRequiredFile':
post:
tags:
- pet
summary: uploads an image
description: ''
operationId: uploadFileWithRequiredFile
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- name: petId
in: path
description: ID of pet to update
required: true
type: integer
format: int64
- name: additionalMetadata
in: formData
description: Additional data to pass to server
required: false
type: string
- name: file
in: formData
description: file to upload
required: true
type: file
responses:
'200':
description: successful operation
schema:
$ref: '#/definitions/ApiResponse'
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
/store/inventory:
get:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ paths:
description: Status values that need to be considered for filter
required: true
style: form
explode: false
schema:
type: array
items:
Expand Down Expand Up @@ -112,7 +111,6 @@ paths:
description: Tags to filter by
required: true
style: form
explode: false
schema:
type: array
items:
Expand Down Expand Up @@ -267,6 +265,47 @@ paths:
description: file to upload
type: string
format: binary
'/pet/{petId}/uploadImageWithRequiredFile':
post:
tags:
- pet
summary: uploads an image
description: ''
operationId: uploadFileWithRequiredFile
parameters:
- name: petId
in: path
description: ID of pet to update
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary
required:
- file
/store/inventory:
get:
tags:
Expand Down Expand Up @@ -436,7 +475,7 @@ paths:
type: integer
format: int32
X-Expires-After:
description: date in UTC when toekn expires
description: date in UTC when token expires
schema:
type: string
format: date-time
Expand Down Expand Up @@ -573,7 +612,6 @@ paths:
parameters:
- name: enum_header_string_array
in: header
explode: true
description: Header parameter enum test (string array)
schema:
type: array
Expand Down Expand Up @@ -876,6 +914,26 @@ paths:
type: string
description: request body
required: true
/fake/body-with-query-params:
put:
tags:
- fake
operationId: testBodyWithQueryParams
parameters:
- name: query
in: query
required: true
schema:
type: string
responses:
'200':
description: Success
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
required: true
/another-fake/dummy:
patch:
tags:
Expand All @@ -892,9 +950,6 @@ paths:
$ref: '#/components/schemas/Client'
requestBody:
$ref: '#/components/requestBodies/Client'
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
components:
requestBodies:
UserArray:
Expand Down Expand Up @@ -1394,6 +1449,7 @@ components:
type: string
OuterBoolean:
type: boolean
x-codegen-body-parameter-name: boolean_post_body
_special_model.name_:
properties:
'$special[property.name]':
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.3-SNAPSHOT
3.0.3
1 change: 1 addition & 0 deletions samples/client/petstore/go/go-petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Class | Method | HTTP request | Description
*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **Put** /pet | Update an existing pet
*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **Post** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **Post** /pet/{petId}/uploadImage | uploads an image
*PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **Post** /pet/{petId}/uploadImageWithRequiredFile | uploads an image
*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **Delete** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **Get** /store/inventory | Returns pet inventories by status
*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **Get** /store/order/{order_id} | Find purchase order by ID
Expand Down
40 changes: 40 additions & 0 deletions samples/client/petstore/go/go-petstore/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,46 @@ paths:
summary: uploads an image
tags:
- pet
/pet/{petId}/uploadImageWithRequiredFile:
post:
operationId: uploadFileWithRequiredFile
parameters:
- description: ID of pet to update
in: path
name: petId
required: true
schema:
format: int64
type: integer
requestBody:
content:
multipart/form-data:
schema:
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
format: binary
type: string
required:
- file
required: true
responses:
200:
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
description: successful operation
security:
- petstore_auth:
- write:pets
- read:pets
summary: uploads an image
tags:
- pet
/store/inventory:
get:
description: Returns a map of status codes to quantities
Expand Down
103 changes: 103 additions & 0 deletions samples/client/petstore/go/go-petstore/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,106 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt

return localVarReturnValue, localVarHttpResponse, nil
}

/*
PetApiService uploads an image
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param petId ID of pet to update
* @param file file to upload
* @param optional nil or *UploadFileWithRequiredFileOpts - Optional Parameters:
* @param "AdditionalMetadata" (optional.String) - Additional data to pass to server
@return ApiResponse
*/

type UploadFileWithRequiredFileOpts struct {
AdditionalMetadata optional.String
}

func (a *PetApiService) UploadFileWithRequiredFile(ctx context.Context, petId int64, file *os.File, localVarOptionals *UploadFileWithRequiredFileOpts) (ApiResponse, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
localVarFileName string
localVarFileBytes []byte
localVarReturnValue ApiResponse
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/pet/{petId}/uploadImageWithRequiredFile"
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHttpContentTypes := []string{"multipart/form-data"}

// 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
}
if localVarOptionals != nil && localVarOptionals.AdditionalMetadata.IsSet() {
localVarFormParams.Add("additionalMetadata", parameterToString(localVarOptionals.AdditionalMetadata.Value(), ""))
}
localVarFile := file
if localVarFile != nil {
fbs, _ := ioutil.ReadAll(localVarFile)
localVarFileBytes = fbs
localVarFileName = localVarFile.Name()
localVarFile.Close()
}
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, localVarHttpResponse, err
}

localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, localVarHttpResponse, err
}

if localVarHttpResponse.StatusCode < 300 {
// If we succeed, return the data, otherwise pass on to decode error.
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
if err == nil {
return localVarReturnValue, localVarHttpResponse, err
}
}

if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
if localVarHttpResponse.StatusCode == 200 {
var v ApiResponse
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}
return localVarReturnValue, localVarHttpResponse, newErr
}

return localVarReturnValue, localVarHttpResponse, nil
}
38 changes: 38 additions & 0 deletions samples/client/petstore/go/go-petstore/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Method | HTTP request | Description
[**UpdatePet**](PetApi.md#UpdatePet) | **Put** /pet | Update an existing pet
[**UpdatePetWithForm**](PetApi.md#UpdatePetWithForm) | **Post** /pet/{petId} | Updates a pet in the store with form data
[**UploadFile**](PetApi.md#UploadFile) | **Post** /pet/{petId}/uploadImage | uploads an image
[**UploadFileWithRequiredFile**](PetApi.md#UploadFileWithRequiredFile) | **Post** /pet/{petId}/uploadImageWithRequiredFile | uploads an image


# **AddPet**
Expand Down Expand Up @@ -257,3 +258,40 @@ Name | Type | Description | Notes

[[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)

# **UploadFileWithRequiredFile**
> ApiResponse UploadFileWithRequiredFile(ctx, petId, file, optional)
uploads an image

### Required Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**petId** | **int64**| ID of pet to update |
**file** | ***os.File*****os.File**| file to upload |
**optional** | ***UploadFileWithRequiredFileOpts** | optional parameters | nil if no parameters

### Optional Parameters
Optional parameters are passed through a pointer to a UploadFileWithRequiredFileOpts struct

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------


**additionalMetadata** | **optional.String**| Additional data to pass to server |

### Return type

[**ApiResponse**](ApiResponse.md)

### Authorization

[petstore_auth](../README.md#petstore_auth)

### HTTP request headers

- **Content-Type**: multipart/form-data
- **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)

Loading