Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Dec 15, 2024
1 parent cbd8691 commit b81520e
Show file tree
Hide file tree
Showing 12 changed files with 682 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,20 @@ public class {{classname}} {
{{! We could also manipulate the inputstream to remove that bad character, but string manipulation is easier to read and this codepath is not asyncronus so we do not gain anything by reading the stream later. }}
{{! This fix does make it unsuitable for large amounts of data because `InputStream.readAllbytes` is not meant for it, but a syncronus client is already not the right tool for that.}}
if (localVarResponse.body() == null) {
return new ApiResponse<{{{returnType}}}>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
return new ApiResponse<{{{returnType}}}>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<{{{returnType}}}>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {})
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {})
);
{{/returnType}}
{{^returnType}}
Expand All @@ -310,7 +310,7 @@ public class {{classname}} {
{{^returnType}}
// Drain the InputStream
while (localVarResponse.body().read() != -1) {
// Ignore
// Ignore
}
localVarResponse.body().close();
{{/returnType}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,21 @@ public ApiResponse<File> testBinaryGifWithHttpInfo() throws ApiException {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("testBinaryGif", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<File>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<File>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<File>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<File>() {})
);
} finally {
}
Expand Down Expand Up @@ -494,10 +505,21 @@ public ApiResponse<Pet> testEchoBodyAllOfPetWithHttpInfo(Pet pet) throws ApiExce
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("testEchoBodyAllOfPet", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Pet>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
);
} finally {
}
Expand Down Expand Up @@ -650,10 +672,21 @@ public ApiResponse<Pet> testEchoBodyPetWithHttpInfo(Pet pet) throws ApiException
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("testEchoBodyPet", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Pet>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
);
} finally {
}
Expand Down Expand Up @@ -806,10 +839,21 @@ public ApiResponse<StringEnumRef> testEchoBodyStringEnumWithHttpInfo(String body
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("testEchoBodyStringEnum", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<StringEnumRef>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<StringEnumRef>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<StringEnumRef>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<StringEnumRef>() {})
);
} finally {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,21 @@ public ApiResponse<Pet> addPetWithHttpInfo(Pet pet) throws ApiException {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("addPet", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Pet>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
);
} finally {
}
Expand Down Expand Up @@ -199,15 +210,15 @@ public ApiResponse<Void> deletePetWithHttpInfo(Long petId, String apiKey) throws
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("deletePet", localVarResponse);
}
return new ApiResponse<Void>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
return new ApiResponse<>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
} finally {
// Drain the InputStream
while (localVarResponse.body().read() != -1) {
// Ignore
// Ignore
}
localVarResponse.body().close();
}
Expand Down Expand Up @@ -280,10 +291,21 @@ public ApiResponse<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status)
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("findPetsByStatus", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<List<Pet>>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<List<Pet>>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<List<Pet>>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {})
);
} finally {
}
Expand Down Expand Up @@ -371,10 +393,21 @@ public ApiResponse<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags) thro
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("findPetsByTags", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<List<Pet>>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<List<Pet>>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<List<Pet>>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<List<Pet>>() {})
);
} finally {
}
Expand Down Expand Up @@ -458,10 +491,21 @@ public ApiResponse<Pet> getPetByIdWithHttpInfo(Long petId) throws ApiException {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("getPetById", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Pet>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
);
} finally {
}
Expand Down Expand Up @@ -535,10 +579,21 @@ public ApiResponse<Pet> updatePetWithHttpInfo(Pet pet) throws ApiException {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("updatePet", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<Pet>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Pet>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<Pet>() {})
);
} finally {
}
Expand Down Expand Up @@ -615,15 +670,15 @@ public ApiResponse<Void> updatePetWithFormWithHttpInfo(Long petId, String name,
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("updatePetWithForm", localVarResponse);
}
return new ApiResponse<Void>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
return new ApiResponse<>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
} finally {
// Drain the InputStream
while (localVarResponse.body().read() != -1) {
// Ignore
// Ignore
}
localVarResponse.body().close();
}
Expand Down Expand Up @@ -714,10 +769,21 @@ public ApiResponse<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String a
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("uploadFile", localVarResponse);
}
if (localVarResponse.body() == null) {
return new ApiResponse<ModelApiResponse>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
}

String responseBody = new String(localVarResponse.body().readAllBytes());
localVarResponse.body().close();

return new ApiResponse<ModelApiResponse>(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<ModelApiResponse>() {}) // closes the InputStream
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<ModelApiResponse>() {})
);
} finally {
}
Expand Down
Loading

0 comments on commit b81520e

Please sign in to comment.