[Python] Add echo_api test object serialization for multipart requests (#18176)

* [python] echo add test object serialization for multipart requests

* [echo api] update samples

* [echo api] update samples
This commit is contained in:
ふぁ
2024-03-23 22:40:10 +09:00
committed by GitHub
parent 420e49f258
commit 5e9546451c
137 changed files with 7427 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ docs/Query.md
docs/QueryApi.md
docs/StringEnumRef.md
docs/Tag.md
docs/TestFormObjectMultipartRequestMarker.md
docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
git_push.sh
@@ -60,5 +61,6 @@ src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/StringEnumRef.java
src/main/java/org/openapitools/client/model/Tag.java
src/main/java/org/openapitools/client/model/TestFormObjectMultipartRequestMarker.java
src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java

View File

@@ -125,6 +125,7 @@ Class | Method | HTTP request | Description
*BodyApi* | [**testEchoBodyStringEnum**](docs/BodyApi.md#testEchoBodyStringEnum) | **POST** /echo/body/string_enum | Test string enum response body
*BodyApi* | [**testEchoBodyTagResponseString**](docs/BodyApi.md#testEchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body)
*FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s)
*FormApi* | [**testFormObjectMultipart**](docs/FormApi.md#testFormObjectMultipart) | **POST** /form/object/multipart | Test form parameter(s) for multipart schema
*FormApi* | [**testFormOneof**](docs/FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema
*HeaderApi* | [**testHeaderIntegerBooleanStringEnums**](docs/HeaderApi.md#testHeaderIntegerBooleanStringEnums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s)
*PathApi* | [**testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](docs/PathApi.md#testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s)
@@ -151,6 +152,7 @@ Class | Method | HTTP request | Description
- [Query](docs/Query.md)
- [StringEnumRef](docs/StringEnumRef.md)
- [Tag](docs/Tag.md)
- [TestFormObjectMultipartRequestMarker](docs/TestFormObjectMultipartRequestMarker.md)
- [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md)
- [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)

View File

@@ -104,6 +104,28 @@ paths:
x-content-type: application/x-www-form-urlencoded
x-accepts:
- text/plain
/form/object/multipart:
post:
description: Test form parameter(s) for multipart schema
operationId: test/form/object/multipart
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/test_form_object_multipart_request'
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test form parameter(s) for multipart schema
tags:
- form
x-content-type: multipart/form-data
x-accepts:
- text/plain
/header/integer/boolean/string/enums:
get:
description: Test header parameter(s)
@@ -933,6 +955,18 @@ components:
- $ref: '#/components/schemas/test_form_oneof_request_oneOf_1'
- $ref: '#/components/schemas/Tag'
type: object
test_form_object_multipart_request_marker:
properties:
name:
type: string
type: object
test_form_object_multipart_request:
properties:
marker:
$ref: '#/components/schemas/test_form_object_multipart_request_marker'
required:
- marker
type: object
test_query_style_form_explode_true_array_string_query_object_parameter:
properties:
values:

View File

@@ -5,6 +5,7 @@ All URIs are relative to *http://localhost:3000*
| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**testFormIntegerBooleanString**](FormApi.md#testFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) |
| [**testFormObjectMultipart**](FormApi.md#testFormObjectMultipart) | **POST** /form/object/multipart | Test form parameter(s) for multipart schema |
| [**testFormOneof**](FormApi.md#testFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema |
@@ -79,6 +80,72 @@ No authorization required
| **200** | Successful operation | - |
## testFormObjectMultipart
> String testFormObjectMultipart(marker)
Test form parameter(s) for multipart schema
Test form parameter(s) for multipart schema
### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.FormApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
FormApi apiInstance = new FormApi(defaultClient);
TestFormObjectMultipartRequestMarker marker = new TestFormObjectMultipartRequestMarker(); // TestFormObjectMultipartRequestMarker |
try {
String result = apiInstance.testFormObjectMultipart(marker);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FormApi#testFormObjectMultipart");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```
### Parameters
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **marker** | [**TestFormObjectMultipartRequestMarker**](TestFormObjectMultipartRequestMarker.md)| | |
### Return type
**String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Successful operation | - |
## testFormOneof
> String testFormOneof(form1, form2, form3, form4, id, name)

View File

@@ -0,0 +1,13 @@
# TestFormObjectMultipartRequestMarker
## Properties
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**name** | **String** | | [optional] |

View File

@@ -20,6 +20,7 @@ import org.openapitools.client.BaseApi;
import org.openapitools.client.Configuration;
import org.openapitools.client.Pair;
import org.openapitools.client.model.TestFormObjectMultipartRequestMarker;
import java.util.ArrayList;
@@ -119,6 +120,82 @@ if (stringForm != null)
);
}
/**
* Test form parameter(s) for multipart schema
* Test form parameter(s) for multipart schema
* @param marker (required)
* @return String
* @throws ApiException if fails to make API call
*/
public String testFormObjectMultipart(TestFormObjectMultipartRequestMarker marker) throws ApiException {
return this.testFormObjectMultipart(marker, Collections.emptyMap());
}
/**
* Test form parameter(s) for multipart schema
* Test form parameter(s) for multipart schema
* @param marker (required)
* @param additionalHeaders additionalHeaders for this call
* @return String
* @throws ApiException if fails to make API call
*/
public String testFormObjectMultipart(TestFormObjectMultipartRequestMarker marker, Map<String, String> additionalHeaders) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'marker' is set
if (marker == null) {
throw new ApiException(400, "Missing the required parameter 'marker' when calling testFormObjectMultipart");
}
// create path and map variables
String localVarPath = "/form/object/multipart";
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarHeaderParams.putAll(additionalHeaders);
if (marker != null)
localVarFormParams.put("marker", marker);
final String[] localVarAccepts = {
"text/plain"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"multipart/form-data"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { };
TypeReference<String> localVarReturnType = new TypeReference<String>() {};
return apiClient.invokeAPI(
localVarPath,
"POST",
localVarQueryParams,
localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(),
localVarPostBody,
localVarHeaderParams,
localVarCookieParams,
localVarFormParams,
localVarAccept,
localVarContentType,
localVarAuthNames,
localVarReturnType
);
}
/**
* Test form parameter(s) for oneOf schema
* Test form parameter(s) for oneOf schema

View File

@@ -0,0 +1,152 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.StringJoiner;
/**
* TestFormObjectMultipartRequestMarker
*/
@JsonPropertyOrder({
TestFormObjectMultipartRequestMarker.JSON_PROPERTY_NAME
})
@JsonTypeName("test_form_object_multipart_request_marker")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.5.0-SNAPSHOT")
public class TestFormObjectMultipartRequestMarker {
public static final String JSON_PROPERTY_NAME = "name";
private String name;
public TestFormObjectMultipartRequestMarker() {
}
public TestFormObjectMultipartRequestMarker name(String name) {
this.name = name;
return this;
}
/**
* Get name
* @return name
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TestFormObjectMultipartRequestMarker testFormObjectMultipartRequestMarker = (TestFormObjectMultipartRequestMarker) o;
return Objects.equals(this.name, testFormObjectMultipartRequestMarker.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TestFormObjectMultipartRequestMarker {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
/**
* Convert the instance into URL query string.
*
* @return URL query string
*/
public String toUrlQueryString() {
return toUrlQueryString(null);
}
/**
* Convert the instance into URL query string.
*
* @param prefix prefix of the query string
* @return URL query string
*/
public String toUrlQueryString(String prefix) {
String suffix = "";
String containerSuffix = "";
String containerPrefix = "";
if (prefix == null) {
// style=form, explode=true, e.g. /pet?name=cat&type=manx
prefix = "";
} else {
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
prefix = prefix + "[";
suffix = "]";
containerSuffix = "]";
containerPrefix = "[";
}
StringJoiner joiner = new StringJoiner("&");
// add `name` to the URL query string
if (getName() != null) {
try {
joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
}
}
return joiner.toString();
}
}

View File

@@ -0,0 +1,47 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for TestFormObjectMultipartRequestMarker
*/
public class TestFormObjectMultipartRequestMarkerTest {
private final TestFormObjectMultipartRequestMarker model = new TestFormObjectMultipartRequestMarker();
/**
* Model tests for TestFormObjectMultipartRequestMarker
*/
@Test
public void testTestFormObjectMultipartRequestMarker() {
// TODO: test TestFormObjectMultipartRequestMarker
}
/**
* Test the property 'name'
*/
@Test
public void nameTest() {
// TODO: test name
}
}