Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,15 @@ namespace {{packageName}}.{{apiPackage}}
{{/headerParams}}
{{#formParams}}
{{#-first}}
MultipartContent multipartContentLocalVar = new MultipartContent();
MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent();

httpRequestMessageLocalVar.Content = multipartContentLocalVar;

List<KeyValuePair<string{{nrt?}}, string{{nrt?}}>> formParameterLocalVars = new List<KeyValuePair<string{{nrt?}}, string{{nrt?}}>>();

multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars));{{/-first}}{{^isFile}}{{#required}}

{{/-first}}
{{^isFile}}
{{#required}}
formParameterLocalVars.Add(new KeyValuePair<string{{nrt?}}, string{{nrt?}}>("{{baseName}}", ClientUtils.ParameterToString({{paramName}})));

{{/required}}
Expand All @@ -490,16 +491,46 @@ namespace {{packageName}}.{{apiPackage}}
{{/isFile}}
{{#isFile}}
{{#required}}
multipartContentLocalVar.Add(new StreamContent({{paramName}}));
{{#isContainer}}
foreach (global::System.IO.Stream streamLocalVar in {{paramName}})
{
var streamContentLocalVar = new StreamContent(streamLocalVar);
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
}

{{/isContainer}}
{{^isContainer}}
var streamContentLocalVar = new StreamContent({{paramName}});
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
Comment thread
devhl-labs marked this conversation as resolved.
Outdated

{{/isContainer}}
{{/required}}
{{^required}}
if ({{paramName}}.IsSet)
multipartContentLocalVar.Add(new StreamContent({{paramName}}.Value));
{
{{#isContainer}}
foreach (global::System.IO.Stream streamLocalVar in {{paramName}}.Value)
{
var streamContentLocalVar = new StreamContent(streamLocalVar);
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
}
{{/isContainer}}
{{^isContainer}}
var streamContentLocalVar = new StreamContent({{paramName}}.Value);
multipartContentLocalVar.Add(streamContentLocalVar, "{{baseName}}");
{{/isContainer}}
}

{{/required}}
{{/isFile}}
{{/formParams}}
{{#formParams}}
{{#-first}}
if (formParameterLocalVars.Count > 0)
multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars));

{{/-first}}
{{/formParams}}
{{#bodyParam}}
{{#required}}
httpRequestMessageLocalVar.Content = ({{paramName}}{{^required}}.Value{{/required}} as object) is System.IO.Stream stream
Expand Down Expand Up @@ -587,10 +618,12 @@ namespace {{packageName}}.{{apiPackage}}
{{#consumes}}
{{#-first}}

{{^formParams}}
string{{nrt?}} contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes);

if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);
{{/formParams}}

{{/-first}}
{{/consumes}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,46 @@ paths:
description: file to upload
type: string
format: binary
'/pet/{petId}/uploadImages':
post:
tags:
- pet
summary: uploads an images
description: ''
operationId: uploadFiles
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:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
files:
type: array
items:
type: string
format: binary
required:
- files
/store/inventory:
get:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,40 @@ paths:
summary: uploads an image
tags:
- pet
/pet/{petId}/uploadImages:
post:
description: ""
operationId: uploadFiles
parameters:
- description: ID of pet to update
explode: false
in: path
name: petId
required: true
schema:
format: int64
type: integer
style: simple
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/uploadFiles_request"
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 images
tags:
- pet
/store/inventory:
get:
description: Returns a map of status codes to quantities
Expand Down Expand Up @@ -2748,6 +2782,16 @@ components:
format: binary
type: string
type: object
uploadFiles_request:
properties:
files:
items:
format: binary
type: string
type: array
required:
- files
type: object
testEnumParameters_request_enum_form_string_array_inner:
default: $
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
| [**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** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) |
| [**UploadFiles**](PetApi.md#uploadfiles) | **POST** /pet/{petId}/uploadImages | uploads an images |

<a id="addpet"></a>
# **AddPet**
Expand Down Expand Up @@ -341,3 +342,38 @@ uploads an image (required)

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

<a id="uploadfiles"></a>
# **UploadFiles**
> ApiResponse UploadFiles (List<System.IO.Stream> files, long petId)

uploads an images


### Parameters

| Name | Type | Description | Notes |
|------|------|-------------|-------|
| **files** | **List&lt;System.IO.Stream&gt;** | | |
| **petId** | **long** | ID of pet to update | |

### Return type

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

### Authorization

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

### HTTP request headers

- **Content-Type**: multipart/form-data
- **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | successful operation | - |

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

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
public async Task FindPetsByTagsAsyncTest()
{
List<string> tags = default;
var response = await _instance.FindPetsByTagsAsync(tags);

Check warning on line 93 in samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs

View workflow job for this annotation

GitHub Actions / Build .Net 10 projects (samples/client/petstore/csharp/generichost/net10/FormModels)

'IPetApi.FindPetsByTagsAsync(List<string>, CancellationToken)' is obsolete
var model = response.Ok();
Assert.IsType<List<Pet>>(model);
}
Expand Down Expand Up @@ -156,5 +156,18 @@
var model = response.Ok();
Assert.IsType<ApiResponse>(model);
}

/// <summary>
/// Test UploadFiles
/// </summary>
[Fact (Skip = "not implemented")]
public async Task UploadFilesAsyncTest()
{
List<System.IO.Stream> files = default;
long petId = default;
var response = await _instance.UploadFilesAsync(files, petId);
var model = response.Ok();
Assert.IsType<ApiResponse>(model);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -764,27 +764,23 @@ public async Task<IGetCountryApiResponse> GetCountryAsync(string country, System
? "/country"
: string.Concat(HttpClient.BaseAddress.AbsolutePath, "/country");

MultipartContent multipartContentLocalVar = new MultipartContent();
MultipartFormDataContent multipartContentLocalVar = new MultipartFormDataContent();
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated

httpRequestMessageLocalVar.Content = multipartContentLocalVar;

List<KeyValuePair<string, string>> formParameterLocalVars = new List<KeyValuePair<string, string>>();

multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars));

formParameterLocalVars.Add(new KeyValuePair<string, string>("country", ClientUtils.ParameterToString(country)));

if (formParameterLocalVars.Count > 0)
multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars));

httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;

string[] contentTypes = new string[] {
"application/x-www-form-urlencoded"
};

string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes);

if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null)
httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar);

httpRequestMessageLocalVar.Method = HttpMethod.Post;

DateTime requestedAtLocalVar = DateTime.UtcNow;
Expand Down
Loading
Loading