forked from loafle/openapi-generator-original
* deserialize enum json response (python) * adapt python samples: adding enum deserialization * add echo test for enum json response deserialization (python) * update samples
This commit is contained in:
@@ -19,6 +19,7 @@ import org.openapitools.client.Pair;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.client.model.Pet;
|
||||
import org.openapitools.client.model.StringEnumRef;
|
||||
import org.openapitools.client.model.Tag;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -765,6 +766,79 @@ public class BodyApi {
|
||||
}
|
||||
return localVarRequestBuilder;
|
||||
}
|
||||
/**
|
||||
* Test string enum response body
|
||||
* Test string enum response body
|
||||
* @param body String enum (optional)
|
||||
* @return StringEnumRef
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public StringEnumRef testEchoBodyStringEnum(String body) throws ApiException {
|
||||
ApiResponse<StringEnumRef> localVarResponse = testEchoBodyStringEnumWithHttpInfo(body);
|
||||
return localVarResponse.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test string enum response body
|
||||
* Test string enum response body
|
||||
* @param body String enum (optional)
|
||||
* @return ApiResponse<StringEnumRef>
|
||||
* @throws ApiException if fails to make API call
|
||||
*/
|
||||
public ApiResponse<StringEnumRef> testEchoBodyStringEnumWithHttpInfo(String body) throws ApiException {
|
||||
HttpRequest.Builder localVarRequestBuilder = testEchoBodyStringEnumRequestBuilder(body);
|
||||
try {
|
||||
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
|
||||
localVarRequestBuilder.build(),
|
||||
HttpResponse.BodyHandlers.ofInputStream());
|
||||
if (memberVarResponseInterceptor != null) {
|
||||
memberVarResponseInterceptor.accept(localVarResponse);
|
||||
}
|
||||
try {
|
||||
if (localVarResponse.statusCode()/ 100 != 2) {
|
||||
throw getApiException("testEchoBodyStringEnum", localVarResponse);
|
||||
}
|
||||
return new ApiResponse<StringEnumRef>(
|
||||
localVarResponse.statusCode(),
|
||||
localVarResponse.headers().map(),
|
||||
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<StringEnumRef>() {}) // closes the InputStream
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ApiException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private HttpRequest.Builder testEchoBodyStringEnumRequestBuilder(String body) throws ApiException {
|
||||
|
||||
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
|
||||
|
||||
String localVarPath = "/echo/body/string_enum";
|
||||
|
||||
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
|
||||
|
||||
localVarRequestBuilder.header("Content-Type", "application/json");
|
||||
localVarRequestBuilder.header("Accept", "application/json");
|
||||
|
||||
try {
|
||||
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body);
|
||||
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
if (memberVarReadTimeout != null) {
|
||||
localVarRequestBuilder.timeout(memberVarReadTimeout);
|
||||
}
|
||||
if (memberVarInterceptor != null) {
|
||||
memberVarInterceptor.accept(localVarRequestBuilder);
|
||||
}
|
||||
return localVarRequestBuilder;
|
||||
}
|
||||
/**
|
||||
* Test empty json (request body)
|
||||
* Test empty json (request body)
|
||||
|
||||
Reference in New Issue
Block a user