diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache index 75779701c40a..3a94f0c6d9fe 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache @@ -56,6 +56,16 @@ import java.util.concurrent.CompletableFuture; {{>generatedAnnotation}} {{#operations}} public class {{classname}} { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -77,6 +87,7 @@ public class {{classname}} { memberVarResponseInterceptor = apiClient.getResponseInterceptor(); memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + {{#asyncNative}} private ApiException getApiException(String operationId, HttpResponse response) { @@ -128,11 +139,40 @@ public class {{classname}} { @Deprecated {{/isDeprecated}} public {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}}{{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture{{/asyncNative}}{{^asyncNative}}void{{/asyncNative}}{{/returnType}} {{operationId}}(API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request apiRequest) throws ApiException { + {{#returnType}}return {{/returnType}}{{^returnType}}{{#asyncNative}}return {{/asyncNative}}{{/returnType}}{{operationId}}(apiRequest, null); + } + + /** + * {{summary}} + * {{notes}} + * @param apiRequest {@link API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request} + * @param headers Optional headers to include in the request + {{#returnType}} + * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}{{returnType}}{{#asyncNative}}>{{/asyncNative}} + {{/returnType}} + {{^returnType}} + {{#asyncNative}} + * @return CompletableFuture<Void> + {{/asyncNative}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}}{{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture{{/asyncNative}}{{^asyncNative}}void{{/asyncNative}}{{/returnType}} {{operationId}}(API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request apiRequest, Map headers) throws ApiException { {{#allParams}} {{>nullable_var_annotations}} {{{dataType}}} {{paramName}} = apiRequest.{{paramName}}(); {{/allParams}} - {{#returnType}}return {{/returnType}}{{^returnType}}{{#asyncNative}}return {{/asyncNative}}{{/returnType}}{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + {{#returnType}}return {{/returnType}}{{^returnType}}{{#asyncNative}}return {{/asyncNative}}{{/returnType}}{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers); } /** @@ -153,10 +193,32 @@ public class {{classname}} { @Deprecated {{/isDeprecated}} public {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}}WithHttpInfo(API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request apiRequest) throws ApiException { + return {{operationId}}WithHttpInfo(apiRequest, null); + } + + /** + * {{summary}} + * {{notes}} + * @param apiRequest {@link API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request} + * @param headers Optional headers to include in the request + * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}}WithHttpInfo(API{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request apiRequest, Map headers) throws ApiException { {{#allParams}} {{{dataType}}} {{paramName}} = apiRequest.{{paramName}}(); {{/allParams}} - return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers); } {{/hasParams}} @@ -188,15 +250,46 @@ public class {{classname}} { @Deprecated {{/isDeprecated}} public {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}}{{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture{{/asyncNative}}{{^asyncNative}}void{{/asyncNative}}{{/returnType}} {{operationId}}({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + {{#returnType}}return {{/returnType}}{{^returnType}}{{#asyncNative}}return {{/asyncNative}}{{/returnType}}{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}null); + } + + /** + * {{summary}} + * {{notes}} + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}} + {{/allParams}} + * @param headers Optional headers to include in the request + {{#returnType}} + * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}{{returnType}}{{#asyncNative}}>{{/asyncNative}} + {{/returnType}} + {{^returnType}} + {{#asyncNative}} + * @return CompletableFuture<Void> + {{/asyncNative}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}}{{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture{{/asyncNative}}{{^asyncNative}}void{{/asyncNative}}{{/returnType}} {{operationId}}({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Map headers) throws ApiException { {{^asyncNative}} - {{#returnType}}ApiResponse<{{{.}}}> localVarResponse = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + {{#returnType}}ApiResponse<{{{.}}}> localVarResponse = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers); {{#returnType}} return localVarResponse.getData(); {{/returnType}} {{/asyncNative}} {{#asyncNative}} try { - HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -244,8 +337,32 @@ public class {{classname}} { @Deprecated {{/isDeprecated}} public {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}}WithHttpInfo({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}null); + } + + /** + * {{summary}} + * {{notes}} + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}} + {{/allParams}} + * @param headers Optional headers to include in the request + * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}} {{operationId}}WithHttpInfo({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Map headers) throws ApiException { {{^asyncNative}} - HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -327,7 +444,7 @@ public class {{classname}} { {{/asyncNative}} {{#asyncNative}} try { - HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -364,7 +481,7 @@ public class {{classname}} { {{/asyncNative}} } - private HttpRequest.Builder {{operationId}}RequestBuilder({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + private HttpRequest.Builder {{operationId}}RequestBuilder({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Map headers) throws ApiException { {{#allParams}} {{#required}} // verify the required parameter '{{paramName}}' is set @@ -569,6 +686,8 @@ public class {{classname}} { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java index 2c5830a3c230..7435a3145523 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java @@ -46,6 +46,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class AuthApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -68,6 +78,7 @@ public AuthApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -88,7 +99,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public String testAuthHttpBasic() throws ApiException { - ApiResponse localVarResponse = testAuthHttpBasicWithHttpInfo(); + return testAuthHttpBasic(null); + } + + /** + * To test HTTP basic authentication + * To test HTTP basic authentication + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testAuthHttpBasic(Map headers) throws ApiException { + ApiResponse localVarResponse = testAuthHttpBasicWithHttpInfo(headers); return localVarResponse.getData(); } @@ -99,7 +121,18 @@ public String testAuthHttpBasic() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse testAuthHttpBasicWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testAuthHttpBasicRequestBuilder(); + return testAuthHttpBasicWithHttpInfo(null); + } + + /** + * To test HTTP basic authentication + * To test HTTP basic authentication + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testAuthHttpBasicWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testAuthHttpBasicRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -135,7 +168,7 @@ public ApiResponse testAuthHttpBasicWithHttpInfo() throws ApiException { } } - private HttpRequest.Builder testAuthHttpBasicRequestBuilder() throws ApiException { + private HttpRequest.Builder testAuthHttpBasicRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -149,6 +182,8 @@ private HttpRequest.Builder testAuthHttpBasicRequestBuilder() throws ApiExceptio if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -162,7 +197,18 @@ private HttpRequest.Builder testAuthHttpBasicRequestBuilder() throws ApiExceptio * @throws ApiException if fails to make API call */ public String testAuthHttpBearer() throws ApiException { - ApiResponse localVarResponse = testAuthHttpBearerWithHttpInfo(); + return testAuthHttpBearer(null); + } + + /** + * To test HTTP bearer authentication + * To test HTTP bearer authentication + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testAuthHttpBearer(Map headers) throws ApiException { + ApiResponse localVarResponse = testAuthHttpBearerWithHttpInfo(headers); return localVarResponse.getData(); } @@ -173,7 +219,18 @@ public String testAuthHttpBearer() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse testAuthHttpBearerWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testAuthHttpBearerRequestBuilder(); + return testAuthHttpBearerWithHttpInfo(null); + } + + /** + * To test HTTP bearer authentication + * To test HTTP bearer authentication + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testAuthHttpBearerWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testAuthHttpBearerRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -209,7 +266,7 @@ public ApiResponse testAuthHttpBearerWithHttpInfo() throws ApiException } } - private HttpRequest.Builder testAuthHttpBearerRequestBuilder() throws ApiException { + private HttpRequest.Builder testAuthHttpBearerRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -223,6 +280,8 @@ private HttpRequest.Builder testAuthHttpBearerRequestBuilder() throws ApiExcepti if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java index 23d8e651cae8..e455da193d3a 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java @@ -56,6 +56,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class BodyApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -78,6 +88,7 @@ public BodyApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -98,7 +109,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public File testBinaryGif() throws ApiException { - ApiResponse localVarResponse = testBinaryGifWithHttpInfo(); + return testBinaryGif(null); + } + + /** + * Test binary (gif) response body + * Test binary (gif) response body + * @param headers Optional headers to include in the request + * @return File + * @throws ApiException if fails to make API call + */ + public File testBinaryGif(Map headers) throws ApiException { + ApiResponse localVarResponse = testBinaryGifWithHttpInfo(headers); return localVarResponse.getData(); } @@ -109,7 +131,18 @@ public File testBinaryGif() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse testBinaryGifWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testBinaryGifRequestBuilder(); + return testBinaryGifWithHttpInfo(null); + } + + /** + * Test binary (gif) response body + * Test binary (gif) response body + * @param headers Optional headers to include in the request + * @return ApiResponse<File> + * @throws ApiException if fails to make API call + */ + public ApiResponse testBinaryGifWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testBinaryGifRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -148,7 +181,7 @@ public ApiResponse testBinaryGifWithHttpInfo() throws ApiException { } } - private HttpRequest.Builder testBinaryGifRequestBuilder() throws ApiException { + private HttpRequest.Builder testBinaryGifRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -162,6 +195,8 @@ private HttpRequest.Builder testBinaryGifRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -176,7 +211,19 @@ private HttpRequest.Builder testBinaryGifRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public String testBodyApplicationOctetstreamBinary(@javax.annotation.Nullable File body) throws ApiException { - ApiResponse localVarResponse = testBodyApplicationOctetstreamBinaryWithHttpInfo(body); + return testBodyApplicationOctetstreamBinary(body, null); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param body (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testBodyApplicationOctetstreamBinary(@javax.annotation.Nullable File body, Map headers) throws ApiException { + ApiResponse localVarResponse = testBodyApplicationOctetstreamBinaryWithHttpInfo(body, headers); return localVarResponse.getData(); } @@ -188,7 +235,19 @@ public String testBodyApplicationOctetstreamBinary(@javax.annotation.Nullable Fi * @throws ApiException if fails to make API call */ public ApiResponse testBodyApplicationOctetstreamBinaryWithHttpInfo(@javax.annotation.Nullable File body) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testBodyApplicationOctetstreamBinaryRequestBuilder(body); + return testBodyApplicationOctetstreamBinaryWithHttpInfo(body, null); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param body (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testBodyApplicationOctetstreamBinaryWithHttpInfo(@javax.annotation.Nullable File body, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testBodyApplicationOctetstreamBinaryRequestBuilder(body, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -224,7 +283,7 @@ public ApiResponse testBodyApplicationOctetstreamBinaryWithHttpInfo(@jav } } - private HttpRequest.Builder testBodyApplicationOctetstreamBinaryRequestBuilder(@javax.annotation.Nullable File body) throws ApiException { + private HttpRequest.Builder testBodyApplicationOctetstreamBinaryRequestBuilder(@javax.annotation.Nullable File body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -244,6 +303,8 @@ private HttpRequest.Builder testBodyApplicationOctetstreamBinaryRequestBuilder(@ if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -258,7 +319,19 @@ private HttpRequest.Builder testBodyApplicationOctetstreamBinaryRequestBuilder(@ * @throws ApiException if fails to make API call */ public String testBodyMultipartFormdataArrayOfBinary(@javax.annotation.Nonnull List files) throws ApiException { - ApiResponse localVarResponse = testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files); + return testBodyMultipartFormdataArrayOfBinary(files, null); + } + + /** + * Test array of binary in multipart mime + * Test array of binary in multipart mime + * @param files (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testBodyMultipartFormdataArrayOfBinary(@javax.annotation.Nonnull List files, Map headers) throws ApiException { + ApiResponse localVarResponse = testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files, headers); return localVarResponse.getData(); } @@ -270,7 +343,19 @@ public String testBodyMultipartFormdataArrayOfBinary(@javax.annotation.Nonnull L * @throws ApiException if fails to make API call */ public ApiResponse testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(@javax.annotation.Nonnull List files) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testBodyMultipartFormdataArrayOfBinaryRequestBuilder(files); + return testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files, null); + } + + /** + * Test array of binary in multipart mime + * Test array of binary in multipart mime + * @param files (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(@javax.annotation.Nonnull List files, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testBodyMultipartFormdataArrayOfBinaryRequestBuilder(files, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -306,7 +391,7 @@ public ApiResponse testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(@j } } - private HttpRequest.Builder testBodyMultipartFormdataArrayOfBinaryRequestBuilder(@javax.annotation.Nonnull List files) throws ApiException { + private HttpRequest.Builder testBodyMultipartFormdataArrayOfBinaryRequestBuilder(@javax.annotation.Nonnull List files, Map headers) throws ApiException { // verify the required parameter 'files' is set if (files == null) { throw new ApiException(400, "Missing the required parameter 'files' when calling testBodyMultipartFormdataArrayOfBinary"); @@ -359,6 +444,8 @@ private HttpRequest.Builder testBodyMultipartFormdataArrayOfBinaryRequestBuilder if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -373,7 +460,19 @@ private HttpRequest.Builder testBodyMultipartFormdataArrayOfBinaryRequestBuilder * @throws ApiException if fails to make API call */ public String testBodyMultipartFormdataSingleBinary(@javax.annotation.Nullable File myFile) throws ApiException { - ApiResponse localVarResponse = testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile); + return testBodyMultipartFormdataSingleBinary(myFile, null); + } + + /** + * Test single binary in multipart mime + * Test single binary in multipart mime + * @param myFile (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testBodyMultipartFormdataSingleBinary(@javax.annotation.Nullable File myFile, Map headers) throws ApiException { + ApiResponse localVarResponse = testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile, headers); return localVarResponse.getData(); } @@ -385,7 +484,19 @@ public String testBodyMultipartFormdataSingleBinary(@javax.annotation.Nullable F * @throws ApiException if fails to make API call */ public ApiResponse testBodyMultipartFormdataSingleBinaryWithHttpInfo(@javax.annotation.Nullable File myFile) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testBodyMultipartFormdataSingleBinaryRequestBuilder(myFile); + return testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile, null); + } + + /** + * Test single binary in multipart mime + * Test single binary in multipart mime + * @param myFile (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testBodyMultipartFormdataSingleBinaryWithHttpInfo(@javax.annotation.Nullable File myFile, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testBodyMultipartFormdataSingleBinaryRequestBuilder(myFile, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -421,7 +532,7 @@ public ApiResponse testBodyMultipartFormdataSingleBinaryWithHttpInfo(@ja } } - private HttpRequest.Builder testBodyMultipartFormdataSingleBinaryRequestBuilder(@javax.annotation.Nullable File myFile) throws ApiException { + private HttpRequest.Builder testBodyMultipartFormdataSingleBinaryRequestBuilder(@javax.annotation.Nullable File myFile, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -468,6 +579,8 @@ private HttpRequest.Builder testBodyMultipartFormdataSingleBinaryRequestBuilder( if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -482,7 +595,19 @@ private HttpRequest.Builder testBodyMultipartFormdataSingleBinaryRequestBuilder( * @throws ApiException if fails to make API call */ public Pet testEchoBodyAllOfPet(@javax.annotation.Nullable Pet pet) throws ApiException { - ApiResponse localVarResponse = testEchoBodyAllOfPetWithHttpInfo(pet); + return testEchoBodyAllOfPet(pet, null); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet testEchoBodyAllOfPet(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = testEchoBodyAllOfPetWithHttpInfo(pet, headers); return localVarResponse.getData(); } @@ -494,7 +619,19 @@ public Pet testEchoBodyAllOfPet(@javax.annotation.Nullable Pet pet) throws ApiEx * @throws ApiException if fails to make API call */ public ApiResponse testEchoBodyAllOfPetWithHttpInfo(@javax.annotation.Nullable Pet pet) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEchoBodyAllOfPetRequestBuilder(pet); + return testEchoBodyAllOfPetWithHttpInfo(pet, null); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEchoBodyAllOfPetWithHttpInfo(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEchoBodyAllOfPetRequestBuilder(pet, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -533,7 +670,7 @@ public ApiResponse testEchoBodyAllOfPetWithHttpInfo(@javax.annotation.Nulla } } - private HttpRequest.Builder testEchoBodyAllOfPetRequestBuilder(@javax.annotation.Nullable Pet pet) throws ApiException { + private HttpRequest.Builder testEchoBodyAllOfPetRequestBuilder(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -553,6 +690,8 @@ private HttpRequest.Builder testEchoBodyAllOfPetRequestBuilder(@javax.annotation if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -567,7 +706,19 @@ private HttpRequest.Builder testEchoBodyAllOfPetRequestBuilder(@javax.annotation * @throws ApiException if fails to make API call */ public String testEchoBodyFreeFormObjectResponseString(@javax.annotation.Nullable Object body) throws ApiException { - ApiResponse localVarResponse = testEchoBodyFreeFormObjectResponseStringWithHttpInfo(body); + return testEchoBodyFreeFormObjectResponseString(body, null); + } + + /** + * Test free form object + * Test free form object + * @param body Free form object (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testEchoBodyFreeFormObjectResponseString(@javax.annotation.Nullable Object body, Map headers) throws ApiException { + ApiResponse localVarResponse = testEchoBodyFreeFormObjectResponseStringWithHttpInfo(body, headers); return localVarResponse.getData(); } @@ -579,7 +730,19 @@ public String testEchoBodyFreeFormObjectResponseString(@javax.annotation.Nullabl * @throws ApiException if fails to make API call */ public ApiResponse testEchoBodyFreeFormObjectResponseStringWithHttpInfo(@javax.annotation.Nullable Object body) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEchoBodyFreeFormObjectResponseStringRequestBuilder(body); + return testEchoBodyFreeFormObjectResponseStringWithHttpInfo(body, null); + } + + /** + * Test free form object + * Test free form object + * @param body Free form object (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEchoBodyFreeFormObjectResponseStringWithHttpInfo(@javax.annotation.Nullable Object body, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEchoBodyFreeFormObjectResponseStringRequestBuilder(body, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -615,7 +778,7 @@ public ApiResponse testEchoBodyFreeFormObjectResponseStringWithHttpInfo( } } - private HttpRequest.Builder testEchoBodyFreeFormObjectResponseStringRequestBuilder(@javax.annotation.Nullable Object body) throws ApiException { + private HttpRequest.Builder testEchoBodyFreeFormObjectResponseStringRequestBuilder(@javax.annotation.Nullable Object body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -635,6 +798,8 @@ private HttpRequest.Builder testEchoBodyFreeFormObjectResponseStringRequestBuild if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -649,7 +814,19 @@ private HttpRequest.Builder testEchoBodyFreeFormObjectResponseStringRequestBuild * @throws ApiException if fails to make API call */ public Pet testEchoBodyPet(@javax.annotation.Nullable Pet pet) throws ApiException { - ApiResponse localVarResponse = testEchoBodyPetWithHttpInfo(pet); + return testEchoBodyPet(pet, null); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet testEchoBodyPet(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = testEchoBodyPetWithHttpInfo(pet, headers); return localVarResponse.getData(); } @@ -661,7 +838,19 @@ public Pet testEchoBodyPet(@javax.annotation.Nullable Pet pet) throws ApiExcepti * @throws ApiException if fails to make API call */ public ApiResponse testEchoBodyPetWithHttpInfo(@javax.annotation.Nullable Pet pet) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEchoBodyPetRequestBuilder(pet); + return testEchoBodyPetWithHttpInfo(pet, null); + } + + /** + * Test body parameter(s) + * Test body parameter(s) + * @param pet Pet object that needs to be added to the store (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEchoBodyPetWithHttpInfo(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEchoBodyPetRequestBuilder(pet, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -700,7 +889,7 @@ public ApiResponse testEchoBodyPetWithHttpInfo(@javax.annotation.Nullable P } } - private HttpRequest.Builder testEchoBodyPetRequestBuilder(@javax.annotation.Nullable Pet pet) throws ApiException { + private HttpRequest.Builder testEchoBodyPetRequestBuilder(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -720,6 +909,8 @@ private HttpRequest.Builder testEchoBodyPetRequestBuilder(@javax.annotation.Null if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -734,7 +925,19 @@ private HttpRequest.Builder testEchoBodyPetRequestBuilder(@javax.annotation.Null * @throws ApiException if fails to make API call */ public String testEchoBodyPetResponseString(@javax.annotation.Nullable Pet pet) throws ApiException { - ApiResponse localVarResponse = testEchoBodyPetResponseStringWithHttpInfo(pet); + return testEchoBodyPetResponseString(pet, null); + } + + /** + * Test empty response body + * Test empty response body + * @param pet Pet object that needs to be added to the store (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testEchoBodyPetResponseString(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = testEchoBodyPetResponseStringWithHttpInfo(pet, headers); return localVarResponse.getData(); } @@ -746,7 +949,19 @@ public String testEchoBodyPetResponseString(@javax.annotation.Nullable Pet pet) * @throws ApiException if fails to make API call */ public ApiResponse testEchoBodyPetResponseStringWithHttpInfo(@javax.annotation.Nullable Pet pet) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEchoBodyPetResponseStringRequestBuilder(pet); + return testEchoBodyPetResponseStringWithHttpInfo(pet, null); + } + + /** + * Test empty response body + * Test empty response body + * @param pet Pet object that needs to be added to the store (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEchoBodyPetResponseStringWithHttpInfo(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEchoBodyPetResponseStringRequestBuilder(pet, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -782,7 +997,7 @@ public ApiResponse testEchoBodyPetResponseStringWithHttpInfo(@javax.anno } } - private HttpRequest.Builder testEchoBodyPetResponseStringRequestBuilder(@javax.annotation.Nullable Pet pet) throws ApiException { + private HttpRequest.Builder testEchoBodyPetResponseStringRequestBuilder(@javax.annotation.Nullable Pet pet, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -802,6 +1017,8 @@ private HttpRequest.Builder testEchoBodyPetResponseStringRequestBuilder(@javax.a if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -816,7 +1033,19 @@ private HttpRequest.Builder testEchoBodyPetResponseStringRequestBuilder(@javax.a * @throws ApiException if fails to make API call */ public StringEnumRef testEchoBodyStringEnum(@javax.annotation.Nullable String body) throws ApiException { - ApiResponse localVarResponse = testEchoBodyStringEnumWithHttpInfo(body); + return testEchoBodyStringEnum(body, null); + } + + /** + * Test string enum response body + * Test string enum response body + * @param body String enum (optional) + * @param headers Optional headers to include in the request + * @return StringEnumRef + * @throws ApiException if fails to make API call + */ + public StringEnumRef testEchoBodyStringEnum(@javax.annotation.Nullable String body, Map headers) throws ApiException { + ApiResponse localVarResponse = testEchoBodyStringEnumWithHttpInfo(body, headers); return localVarResponse.getData(); } @@ -828,7 +1057,19 @@ public StringEnumRef testEchoBodyStringEnum(@javax.annotation.Nullable String bo * @throws ApiException if fails to make API call */ public ApiResponse testEchoBodyStringEnumWithHttpInfo(@javax.annotation.Nullable String body) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEchoBodyStringEnumRequestBuilder(body); + return testEchoBodyStringEnumWithHttpInfo(body, null); + } + + /** + * Test string enum response body + * Test string enum response body + * @param body String enum (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<StringEnumRef> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEchoBodyStringEnumWithHttpInfo(@javax.annotation.Nullable String body, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEchoBodyStringEnumRequestBuilder(body, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -867,7 +1108,7 @@ public ApiResponse testEchoBodyStringEnumWithHttpInfo(@javax.anno } } - private HttpRequest.Builder testEchoBodyStringEnumRequestBuilder(@javax.annotation.Nullable String body) throws ApiException { + private HttpRequest.Builder testEchoBodyStringEnumRequestBuilder(@javax.annotation.Nullable String body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -887,6 +1128,8 @@ private HttpRequest.Builder testEchoBodyStringEnumRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -901,7 +1144,19 @@ private HttpRequest.Builder testEchoBodyStringEnumRequestBuilder(@javax.annotati * @throws ApiException if fails to make API call */ public String testEchoBodyTagResponseString(@javax.annotation.Nullable Tag tag) throws ApiException { - ApiResponse localVarResponse = testEchoBodyTagResponseStringWithHttpInfo(tag); + return testEchoBodyTagResponseString(tag, null); + } + + /** + * Test empty json (request body) + * Test empty json (request body) + * @param tag Tag object (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testEchoBodyTagResponseString(@javax.annotation.Nullable Tag tag, Map headers) throws ApiException { + ApiResponse localVarResponse = testEchoBodyTagResponseStringWithHttpInfo(tag, headers); return localVarResponse.getData(); } @@ -913,7 +1168,19 @@ public String testEchoBodyTagResponseString(@javax.annotation.Nullable Tag tag) * @throws ApiException if fails to make API call */ public ApiResponse testEchoBodyTagResponseStringWithHttpInfo(@javax.annotation.Nullable Tag tag) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEchoBodyTagResponseStringRequestBuilder(tag); + return testEchoBodyTagResponseStringWithHttpInfo(tag, null); + } + + /** + * Test empty json (request body) + * Test empty json (request body) + * @param tag Tag object (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEchoBodyTagResponseStringWithHttpInfo(@javax.annotation.Nullable Tag tag, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEchoBodyTagResponseStringRequestBuilder(tag, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -949,7 +1216,7 @@ public ApiResponse testEchoBodyTagResponseStringWithHttpInfo(@javax.anno } } - private HttpRequest.Builder testEchoBodyTagResponseStringRequestBuilder(@javax.annotation.Nullable Tag tag) throws ApiException { + private HttpRequest.Builder testEchoBodyTagResponseStringRequestBuilder(@javax.annotation.Nullable Tag tag, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -969,6 +1236,8 @@ private HttpRequest.Builder testEchoBodyTagResponseStringRequestBuilder(@javax.a if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java index d5c55e28f841..545a2133ecb6 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java @@ -53,6 +53,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class FormApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -75,6 +85,7 @@ public FormApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -98,7 +109,21 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public String testFormIntegerBooleanString(@javax.annotation.Nullable Integer integerForm, @javax.annotation.Nullable Boolean booleanForm, @javax.annotation.Nullable String stringForm) throws ApiException { - ApiResponse localVarResponse = testFormIntegerBooleanStringWithHttpInfo(integerForm, booleanForm, stringForm); + return testFormIntegerBooleanString(integerForm, booleanForm, stringForm, null); + } + + /** + * Test form parameter(s) + * Test form parameter(s) + * @param integerForm (optional) + * @param booleanForm (optional) + * @param stringForm (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testFormIntegerBooleanString(@javax.annotation.Nullable Integer integerForm, @javax.annotation.Nullable Boolean booleanForm, @javax.annotation.Nullable String stringForm, Map headers) throws ApiException { + ApiResponse localVarResponse = testFormIntegerBooleanStringWithHttpInfo(integerForm, booleanForm, stringForm, headers); return localVarResponse.getData(); } @@ -112,7 +137,21 @@ public String testFormIntegerBooleanString(@javax.annotation.Nullable Integer in * @throws ApiException if fails to make API call */ public ApiResponse testFormIntegerBooleanStringWithHttpInfo(@javax.annotation.Nullable Integer integerForm, @javax.annotation.Nullable Boolean booleanForm, @javax.annotation.Nullable String stringForm) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testFormIntegerBooleanStringRequestBuilder(integerForm, booleanForm, stringForm); + return testFormIntegerBooleanStringWithHttpInfo(integerForm, booleanForm, stringForm, null); + } + + /** + * Test form parameter(s) + * Test form parameter(s) + * @param integerForm (optional) + * @param booleanForm (optional) + * @param stringForm (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testFormIntegerBooleanStringWithHttpInfo(@javax.annotation.Nullable Integer integerForm, @javax.annotation.Nullable Boolean booleanForm, @javax.annotation.Nullable String stringForm, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testFormIntegerBooleanStringRequestBuilder(integerForm, booleanForm, stringForm, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -148,7 +187,7 @@ public ApiResponse testFormIntegerBooleanStringWithHttpInfo(@javax.annot } } - private HttpRequest.Builder testFormIntegerBooleanStringRequestBuilder(@javax.annotation.Nullable Integer integerForm, @javax.annotation.Nullable Boolean booleanForm, @javax.annotation.Nullable String stringForm) throws ApiException { + private HttpRequest.Builder testFormIntegerBooleanStringRequestBuilder(@javax.annotation.Nullable Integer integerForm, @javax.annotation.Nullable Boolean booleanForm, @javax.annotation.Nullable String stringForm, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -182,6 +221,8 @@ private HttpRequest.Builder testFormIntegerBooleanStringRequestBuilder(@javax.an if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -196,7 +237,19 @@ private HttpRequest.Builder testFormIntegerBooleanStringRequestBuilder(@javax.an * @throws ApiException if fails to make API call */ public String testFormObjectMultipart(@javax.annotation.Nonnull TestFormObjectMultipartRequestMarker marker) throws ApiException { - ApiResponse localVarResponse = testFormObjectMultipartWithHttpInfo(marker); + return testFormObjectMultipart(marker, null); + } + + /** + * Test form parameter(s) for multipart schema + * Test form parameter(s) for multipart schema + * @param marker (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testFormObjectMultipart(@javax.annotation.Nonnull TestFormObjectMultipartRequestMarker marker, Map headers) throws ApiException { + ApiResponse localVarResponse = testFormObjectMultipartWithHttpInfo(marker, headers); return localVarResponse.getData(); } @@ -208,7 +261,19 @@ public String testFormObjectMultipart(@javax.annotation.Nonnull TestFormObjectMu * @throws ApiException if fails to make API call */ public ApiResponse testFormObjectMultipartWithHttpInfo(@javax.annotation.Nonnull TestFormObjectMultipartRequestMarker marker) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testFormObjectMultipartRequestBuilder(marker); + return testFormObjectMultipartWithHttpInfo(marker, null); + } + + /** + * Test form parameter(s) for multipart schema + * Test form parameter(s) for multipart schema + * @param marker (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testFormObjectMultipartWithHttpInfo(@javax.annotation.Nonnull TestFormObjectMultipartRequestMarker marker, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testFormObjectMultipartRequestBuilder(marker, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -244,7 +309,7 @@ public ApiResponse testFormObjectMultipartWithHttpInfo(@javax.annotation } } - private HttpRequest.Builder testFormObjectMultipartRequestBuilder(@javax.annotation.Nonnull TestFormObjectMultipartRequestMarker marker) throws ApiException { + private HttpRequest.Builder testFormObjectMultipartRequestBuilder(@javax.annotation.Nonnull TestFormObjectMultipartRequestMarker marker, Map headers) throws ApiException { // verify the required parameter 'marker' is set if (marker == null) { throw new ApiException(400, "Missing the required parameter 'marker' when calling testFormObjectMultipart"); @@ -296,6 +361,8 @@ private HttpRequest.Builder testFormObjectMultipartRequestBuilder(@javax.annotat if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -315,7 +382,24 @@ private HttpRequest.Builder testFormObjectMultipartRequestBuilder(@javax.annotat * @throws ApiException if fails to make API call */ public String testFormOneof(@javax.annotation.Nullable String form1, @javax.annotation.Nullable Integer form2, @javax.annotation.Nullable String form3, @javax.annotation.Nullable Boolean form4, @javax.annotation.Nullable Long id, @javax.annotation.Nullable String name) throws ApiException { - ApiResponse localVarResponse = testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name); + return testFormOneof(form1, form2, form3, form4, id, name, null); + } + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testFormOneof(@javax.annotation.Nullable String form1, @javax.annotation.Nullable Integer form2, @javax.annotation.Nullable String form3, @javax.annotation.Nullable Boolean form4, @javax.annotation.Nullable Long id, @javax.annotation.Nullable String name, Map headers) throws ApiException { + ApiResponse localVarResponse = testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name, headers); return localVarResponse.getData(); } @@ -332,7 +416,24 @@ public String testFormOneof(@javax.annotation.Nullable String form1, @javax.anno * @throws ApiException if fails to make API call */ public ApiResponse testFormOneofWithHttpInfo(@javax.annotation.Nullable String form1, @javax.annotation.Nullable Integer form2, @javax.annotation.Nullable String form3, @javax.annotation.Nullable Boolean form4, @javax.annotation.Nullable Long id, @javax.annotation.Nullable String name) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testFormOneofRequestBuilder(form1, form2, form3, form4, id, name); + return testFormOneofWithHttpInfo(form1, form2, form3, form4, id, name, null); + } + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testFormOneofWithHttpInfo(@javax.annotation.Nullable String form1, @javax.annotation.Nullable Integer form2, @javax.annotation.Nullable String form3, @javax.annotation.Nullable Boolean form4, @javax.annotation.Nullable Long id, @javax.annotation.Nullable String name, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testFormOneofRequestBuilder(form1, form2, form3, form4, id, name, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -368,7 +469,7 @@ public ApiResponse testFormOneofWithHttpInfo(@javax.annotation.Nullable } } - private HttpRequest.Builder testFormOneofRequestBuilder(@javax.annotation.Nullable String form1, @javax.annotation.Nullable Integer form2, @javax.annotation.Nullable String form3, @javax.annotation.Nullable Boolean form4, @javax.annotation.Nullable Long id, @javax.annotation.Nullable String name) throws ApiException { + private HttpRequest.Builder testFormOneofRequestBuilder(@javax.annotation.Nullable String form1, @javax.annotation.Nullable Integer form2, @javax.annotation.Nullable String form3, @javax.annotation.Nullable Boolean form4, @javax.annotation.Nullable Long id, @javax.annotation.Nullable String name, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -411,6 +512,8 @@ private HttpRequest.Builder testFormOneofRequestBuilder(@javax.annotation.Nullab if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java index b44830548e85..204b13411777 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java @@ -53,6 +53,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class HeaderApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -75,6 +85,7 @@ public HeaderApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -100,7 +111,23 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public String testHeaderIntegerBooleanStringEnums(@javax.annotation.Nullable Integer integerHeader, @javax.annotation.Nullable Boolean booleanHeader, @javax.annotation.Nullable String stringHeader, @javax.annotation.Nullable String enumNonrefStringHeader, @javax.annotation.Nullable StringEnumRef enumRefStringHeader) throws ApiException { - ApiResponse localVarResponse = testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader); + return testHeaderIntegerBooleanStringEnums(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader, null); + } + + /** + * Test header parameter(s) + * Test header parameter(s) + * @param integerHeader (optional) + * @param booleanHeader (optional) + * @param stringHeader (optional) + * @param enumNonrefStringHeader (optional) + * @param enumRefStringHeader (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testHeaderIntegerBooleanStringEnums(@javax.annotation.Nullable Integer integerHeader, @javax.annotation.Nullable Boolean booleanHeader, @javax.annotation.Nullable String stringHeader, @javax.annotation.Nullable String enumNonrefStringHeader, @javax.annotation.Nullable StringEnumRef enumRefStringHeader, Map headers) throws ApiException { + ApiResponse localVarResponse = testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader, headers); return localVarResponse.getData(); } @@ -116,7 +143,23 @@ public String testHeaderIntegerBooleanStringEnums(@javax.annotation.Nullable Int * @throws ApiException if fails to make API call */ public ApiResponse testHeaderIntegerBooleanStringEnumsWithHttpInfo(@javax.annotation.Nullable Integer integerHeader, @javax.annotation.Nullable Boolean booleanHeader, @javax.annotation.Nullable String stringHeader, @javax.annotation.Nullable String enumNonrefStringHeader, @javax.annotation.Nullable StringEnumRef enumRefStringHeader) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testHeaderIntegerBooleanStringEnumsRequestBuilder(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader); + return testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader, null); + } + + /** + * Test header parameter(s) + * Test header parameter(s) + * @param integerHeader (optional) + * @param booleanHeader (optional) + * @param stringHeader (optional) + * @param enumNonrefStringHeader (optional) + * @param enumRefStringHeader (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testHeaderIntegerBooleanStringEnumsWithHttpInfo(@javax.annotation.Nullable Integer integerHeader, @javax.annotation.Nullable Boolean booleanHeader, @javax.annotation.Nullable String stringHeader, @javax.annotation.Nullable String enumNonrefStringHeader, @javax.annotation.Nullable StringEnumRef enumRefStringHeader, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testHeaderIntegerBooleanStringEnumsRequestBuilder(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -152,7 +195,7 @@ public ApiResponse testHeaderIntegerBooleanStringEnumsWithHttpInfo(@java } } - private HttpRequest.Builder testHeaderIntegerBooleanStringEnumsRequestBuilder(@javax.annotation.Nullable Integer integerHeader, @javax.annotation.Nullable Boolean booleanHeader, @javax.annotation.Nullable String stringHeader, @javax.annotation.Nullable String enumNonrefStringHeader, @javax.annotation.Nullable StringEnumRef enumRefStringHeader) throws ApiException { + private HttpRequest.Builder testHeaderIntegerBooleanStringEnumsRequestBuilder(@javax.annotation.Nullable Integer integerHeader, @javax.annotation.Nullable Boolean booleanHeader, @javax.annotation.Nullable String stringHeader, @javax.annotation.Nullable String enumNonrefStringHeader, @javax.annotation.Nullable StringEnumRef enumRefStringHeader, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -181,6 +224,8 @@ private HttpRequest.Builder testHeaderIntegerBooleanStringEnumsRequestBuilder(@j if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java index 9757e2287011..fd0d90787a51 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java @@ -53,6 +53,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class PathApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -75,6 +85,7 @@ public PathApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -99,7 +110,22 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(@javax.annotation.Nonnull String pathString, @javax.annotation.Nonnull Integer pathInteger, @javax.annotation.Nonnull String enumNonrefStringPath, @javax.annotation.Nonnull StringEnumRef enumRefStringPath) throws ApiException { - ApiResponse localVarResponse = testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath); + return testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath, null); + } + + /** + * Test path parameter(s) + * Test path parameter(s) + * @param pathString (required) + * @param pathInteger (required) + * @param enumNonrefStringPath (required) + * @param enumRefStringPath (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(@javax.annotation.Nonnull String pathString, @javax.annotation.Nonnull Integer pathInteger, @javax.annotation.Nonnull String enumNonrefStringPath, @javax.annotation.Nonnull StringEnumRef enumRefStringPath, Map headers) throws ApiException { + ApiResponse localVarResponse = testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath, headers); return localVarResponse.getData(); } @@ -114,7 +140,22 @@ public String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnu * @throws ApiException if fails to make API call */ public ApiResponse testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(@javax.annotation.Nonnull String pathString, @javax.annotation.Nonnull Integer pathInteger, @javax.annotation.Nonnull String enumNonrefStringPath, @javax.annotation.Nonnull StringEnumRef enumRefStringPath) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequestBuilder(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath); + return testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath, null); + } + + /** + * Test path parameter(s) + * Test path parameter(s) + * @param pathString (required) + * @param pathInteger (required) + * @param enumNonrefStringPath (required) + * @param enumRefStringPath (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(@javax.annotation.Nonnull String pathString, @javax.annotation.Nonnull Integer pathInteger, @javax.annotation.Nonnull String enumNonrefStringPath, @javax.annotation.Nonnull StringEnumRef enumRefStringPath, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequestBuilder(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -150,7 +191,7 @@ public ApiResponse testsPathStringPathStringIntegerPathIntegerEnumNonref } } - private HttpRequest.Builder testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequestBuilder(@javax.annotation.Nonnull String pathString, @javax.annotation.Nonnull Integer pathInteger, @javax.annotation.Nonnull String enumNonrefStringPath, @javax.annotation.Nonnull StringEnumRef enumRefStringPath) throws ApiException { + private HttpRequest.Builder testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequestBuilder(@javax.annotation.Nonnull String pathString, @javax.annotation.Nonnull Integer pathInteger, @javax.annotation.Nonnull String enumNonrefStringPath, @javax.annotation.Nonnull StringEnumRef enumRefStringPath, Map headers) throws ApiException { // verify the required parameter 'pathString' is set if (pathString == null) { throw new ApiException(400, "Missing the required parameter 'pathString' when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath"); @@ -184,6 +225,8 @@ private HttpRequest.Builder testsPathStringPathStringIntegerPathIntegerEnumNonre if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java index 05c4257eac70..d196e933d358 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java @@ -59,6 +59,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class QueryApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -81,6 +91,7 @@ public QueryApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -103,7 +114,20 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public String testEnumRefString(@javax.annotation.Nullable String enumNonrefStringQuery, @javax.annotation.Nullable StringEnumRef enumRefStringQuery) throws ApiException { - ApiResponse localVarResponse = testEnumRefStringWithHttpInfo(enumNonrefStringQuery, enumRefStringQuery); + return testEnumRefString(enumNonrefStringQuery, enumRefStringQuery, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param enumNonrefStringQuery (optional) + * @param enumRefStringQuery (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testEnumRefString(@javax.annotation.Nullable String enumNonrefStringQuery, @javax.annotation.Nullable StringEnumRef enumRefStringQuery, Map headers) throws ApiException { + ApiResponse localVarResponse = testEnumRefStringWithHttpInfo(enumNonrefStringQuery, enumRefStringQuery, headers); return localVarResponse.getData(); } @@ -116,7 +140,20 @@ public String testEnumRefString(@javax.annotation.Nullable String enumNonrefStri * @throws ApiException if fails to make API call */ public ApiResponse testEnumRefStringWithHttpInfo(@javax.annotation.Nullable String enumNonrefStringQuery, @javax.annotation.Nullable StringEnumRef enumRefStringQuery) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEnumRefStringRequestBuilder(enumNonrefStringQuery, enumRefStringQuery); + return testEnumRefStringWithHttpInfo(enumNonrefStringQuery, enumRefStringQuery, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param enumNonrefStringQuery (optional) + * @param enumRefStringQuery (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEnumRefStringWithHttpInfo(@javax.annotation.Nullable String enumNonrefStringQuery, @javax.annotation.Nullable StringEnumRef enumRefStringQuery, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEnumRefStringRequestBuilder(enumNonrefStringQuery, enumRefStringQuery, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -152,7 +189,7 @@ public ApiResponse testEnumRefStringWithHttpInfo(@javax.annotation.Nulla } } - private HttpRequest.Builder testEnumRefStringRequestBuilder(@javax.annotation.Nullable String enumNonrefStringQuery, @javax.annotation.Nullable StringEnumRef enumRefStringQuery) throws ApiException { + private HttpRequest.Builder testEnumRefStringRequestBuilder(@javax.annotation.Nullable String enumNonrefStringQuery, @javax.annotation.Nullable StringEnumRef enumRefStringQuery, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -183,6 +220,8 @@ private HttpRequest.Builder testEnumRefStringRequestBuilder(@javax.annotation.Nu if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -199,7 +238,21 @@ private HttpRequest.Builder testEnumRefStringRequestBuilder(@javax.annotation.Nu * @throws ApiException if fails to make API call */ public String testQueryDatetimeDateString(@javax.annotation.Nullable Instant datetimeQuery, @javax.annotation.Nullable LocalDate dateQuery, @javax.annotation.Nullable String stringQuery) throws ApiException { - ApiResponse localVarResponse = testQueryDatetimeDateStringWithHttpInfo(datetimeQuery, dateQuery, stringQuery); + return testQueryDatetimeDateString(datetimeQuery, dateQuery, stringQuery, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param datetimeQuery (optional) + * @param dateQuery (optional) + * @param stringQuery (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryDatetimeDateString(@javax.annotation.Nullable Instant datetimeQuery, @javax.annotation.Nullable LocalDate dateQuery, @javax.annotation.Nullable String stringQuery, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryDatetimeDateStringWithHttpInfo(datetimeQuery, dateQuery, stringQuery, headers); return localVarResponse.getData(); } @@ -213,7 +266,21 @@ public String testQueryDatetimeDateString(@javax.annotation.Nullable Instant dat * @throws ApiException if fails to make API call */ public ApiResponse testQueryDatetimeDateStringWithHttpInfo(@javax.annotation.Nullable Instant datetimeQuery, @javax.annotation.Nullable LocalDate dateQuery, @javax.annotation.Nullable String stringQuery) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryDatetimeDateStringRequestBuilder(datetimeQuery, dateQuery, stringQuery); + return testQueryDatetimeDateStringWithHttpInfo(datetimeQuery, dateQuery, stringQuery, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param datetimeQuery (optional) + * @param dateQuery (optional) + * @param stringQuery (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryDatetimeDateStringWithHttpInfo(@javax.annotation.Nullable Instant datetimeQuery, @javax.annotation.Nullable LocalDate dateQuery, @javax.annotation.Nullable String stringQuery, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryDatetimeDateStringRequestBuilder(datetimeQuery, dateQuery, stringQuery, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -249,7 +316,7 @@ public ApiResponse testQueryDatetimeDateStringWithHttpInfo(@javax.annota } } - private HttpRequest.Builder testQueryDatetimeDateStringRequestBuilder(@javax.annotation.Nullable Instant datetimeQuery, @javax.annotation.Nullable LocalDate dateQuery, @javax.annotation.Nullable String stringQuery) throws ApiException { + private HttpRequest.Builder testQueryDatetimeDateStringRequestBuilder(@javax.annotation.Nullable Instant datetimeQuery, @javax.annotation.Nullable LocalDate dateQuery, @javax.annotation.Nullable String stringQuery, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -282,6 +349,8 @@ private HttpRequest.Builder testQueryDatetimeDateStringRequestBuilder(@javax.ann if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -298,7 +367,21 @@ private HttpRequest.Builder testQueryDatetimeDateStringRequestBuilder(@javax.ann * @throws ApiException if fails to make API call */ public String testQueryIntegerBooleanString(@javax.annotation.Nullable Integer integerQuery, @javax.annotation.Nullable Boolean booleanQuery, @javax.annotation.Nullable String stringQuery) throws ApiException { - ApiResponse localVarResponse = testQueryIntegerBooleanStringWithHttpInfo(integerQuery, booleanQuery, stringQuery); + return testQueryIntegerBooleanString(integerQuery, booleanQuery, stringQuery, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param integerQuery (optional) + * @param booleanQuery (optional) + * @param stringQuery (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryIntegerBooleanString(@javax.annotation.Nullable Integer integerQuery, @javax.annotation.Nullable Boolean booleanQuery, @javax.annotation.Nullable String stringQuery, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryIntegerBooleanStringWithHttpInfo(integerQuery, booleanQuery, stringQuery, headers); return localVarResponse.getData(); } @@ -312,7 +395,21 @@ public String testQueryIntegerBooleanString(@javax.annotation.Nullable Integer i * @throws ApiException if fails to make API call */ public ApiResponse testQueryIntegerBooleanStringWithHttpInfo(@javax.annotation.Nullable Integer integerQuery, @javax.annotation.Nullable Boolean booleanQuery, @javax.annotation.Nullable String stringQuery) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryIntegerBooleanStringRequestBuilder(integerQuery, booleanQuery, stringQuery); + return testQueryIntegerBooleanStringWithHttpInfo(integerQuery, booleanQuery, stringQuery, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param integerQuery (optional) + * @param booleanQuery (optional) + * @param stringQuery (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryIntegerBooleanStringWithHttpInfo(@javax.annotation.Nullable Integer integerQuery, @javax.annotation.Nullable Boolean booleanQuery, @javax.annotation.Nullable String stringQuery, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryIntegerBooleanStringRequestBuilder(integerQuery, booleanQuery, stringQuery, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -348,7 +445,7 @@ public ApiResponse testQueryIntegerBooleanStringWithHttpInfo(@javax.anno } } - private HttpRequest.Builder testQueryIntegerBooleanStringRequestBuilder(@javax.annotation.Nullable Integer integerQuery, @javax.annotation.Nullable Boolean booleanQuery, @javax.annotation.Nullable String stringQuery) throws ApiException { + private HttpRequest.Builder testQueryIntegerBooleanStringRequestBuilder(@javax.annotation.Nullable Integer integerQuery, @javax.annotation.Nullable Boolean booleanQuery, @javax.annotation.Nullable String stringQuery, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -381,6 +478,8 @@ private HttpRequest.Builder testQueryIntegerBooleanStringRequestBuilder(@javax.a if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -395,7 +494,19 @@ private HttpRequest.Builder testQueryIntegerBooleanStringRequestBuilder(@javax.a * @throws ApiException if fails to make API call */ public String testQueryStyleDeepObjectExplodeTrueObject(@javax.annotation.Nullable Pet queryObject) throws ApiException { - ApiResponse localVarResponse = testQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo(queryObject); + return testQueryStyleDeepObjectExplodeTrueObject(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleDeepObjectExplodeTrueObject(@javax.annotation.Nullable Pet queryObject, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo(queryObject, headers); return localVarResponse.getData(); } @@ -407,7 +518,19 @@ public String testQueryStyleDeepObjectExplodeTrueObject(@javax.annotation.Nullab * @throws ApiException if fails to make API call */ public ApiResponse testQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo(@javax.annotation.Nullable Pet queryObject) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryStyleDeepObjectExplodeTrueObjectRequestBuilder(queryObject); + return testQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo(@javax.annotation.Nullable Pet queryObject, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleDeepObjectExplodeTrueObjectRequestBuilder(queryObject, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -443,7 +566,7 @@ public ApiResponse testQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo } } - private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectRequestBuilder(@javax.annotation.Nullable Pet queryObject) throws ApiException { + private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectRequestBuilder(@javax.annotation.Nullable Pet queryObject, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -477,6 +600,8 @@ private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectRequestBuil if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -491,7 +616,19 @@ private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectRequestBuil * @throws ApiException if fails to make API call */ public String testQueryStyleDeepObjectExplodeTrueObjectAllOf(@javax.annotation.Nullable TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter queryObject) throws ApiException { - ApiResponse localVarResponse = testQueryStyleDeepObjectExplodeTrueObjectAllOfWithHttpInfo(queryObject); + return testQueryStyleDeepObjectExplodeTrueObjectAllOf(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleDeepObjectExplodeTrueObjectAllOf(@javax.annotation.Nullable TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter queryObject, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryStyleDeepObjectExplodeTrueObjectAllOfWithHttpInfo(queryObject, headers); return localVarResponse.getData(); } @@ -503,7 +640,19 @@ public String testQueryStyleDeepObjectExplodeTrueObjectAllOf(@javax.annotation.N * @throws ApiException if fails to make API call */ public ApiResponse testQueryStyleDeepObjectExplodeTrueObjectAllOfWithHttpInfo(@javax.annotation.Nullable TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter queryObject) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryStyleDeepObjectExplodeTrueObjectAllOfRequestBuilder(queryObject); + return testQueryStyleDeepObjectExplodeTrueObjectAllOfWithHttpInfo(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleDeepObjectExplodeTrueObjectAllOfWithHttpInfo(@javax.annotation.Nullable TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter queryObject, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleDeepObjectExplodeTrueObjectAllOfRequestBuilder(queryObject, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -539,7 +688,7 @@ public ApiResponse testQueryStyleDeepObjectExplodeTrueObjectAllOfWithHtt } } - private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectAllOfRequestBuilder(@javax.annotation.Nullable TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter queryObject) throws ApiException { + private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectAllOfRequestBuilder(@javax.annotation.Nullable TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter queryObject, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -573,6 +722,8 @@ private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectAllOfReques if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -587,7 +738,19 @@ private HttpRequest.Builder testQueryStyleDeepObjectExplodeTrueObjectAllOfReques * @throws ApiException if fails to make API call */ public String testQueryStyleFormExplodeFalseArrayInteger(@javax.annotation.Nullable List queryObject) throws ApiException { - ApiResponse localVarResponse = testQueryStyleFormExplodeFalseArrayIntegerWithHttpInfo(queryObject); + return testQueryStyleFormExplodeFalseArrayInteger(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleFormExplodeFalseArrayInteger(@javax.annotation.Nullable List queryObject, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryStyleFormExplodeFalseArrayIntegerWithHttpInfo(queryObject, headers); return localVarResponse.getData(); } @@ -599,7 +762,19 @@ public String testQueryStyleFormExplodeFalseArrayInteger(@javax.annotation.Nulla * @throws ApiException if fails to make API call */ public ApiResponse testQueryStyleFormExplodeFalseArrayIntegerWithHttpInfo(@javax.annotation.Nullable List queryObject) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeFalseArrayIntegerRequestBuilder(queryObject); + return testQueryStyleFormExplodeFalseArrayIntegerWithHttpInfo(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleFormExplodeFalseArrayIntegerWithHttpInfo(@javax.annotation.Nullable List queryObject, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeFalseArrayIntegerRequestBuilder(queryObject, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -635,7 +810,7 @@ public ApiResponse testQueryStyleFormExplodeFalseArrayIntegerWithHttpInf } } - private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayIntegerRequestBuilder(@javax.annotation.Nullable List queryObject) throws ApiException { + private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayIntegerRequestBuilder(@javax.annotation.Nullable List queryObject, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -664,6 +839,8 @@ private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayIntegerRequestBui if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -678,7 +855,19 @@ private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayIntegerRequestBui * @throws ApiException if fails to make API call */ public String testQueryStyleFormExplodeFalseArrayString(@javax.annotation.Nullable List queryObject) throws ApiException { - ApiResponse localVarResponse = testQueryStyleFormExplodeFalseArrayStringWithHttpInfo(queryObject); + return testQueryStyleFormExplodeFalseArrayString(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleFormExplodeFalseArrayString(@javax.annotation.Nullable List queryObject, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryStyleFormExplodeFalseArrayStringWithHttpInfo(queryObject, headers); return localVarResponse.getData(); } @@ -690,7 +879,19 @@ public String testQueryStyleFormExplodeFalseArrayString(@javax.annotation.Nullab * @throws ApiException if fails to make API call */ public ApiResponse testQueryStyleFormExplodeFalseArrayStringWithHttpInfo(@javax.annotation.Nullable List queryObject) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeFalseArrayStringRequestBuilder(queryObject); + return testQueryStyleFormExplodeFalseArrayStringWithHttpInfo(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleFormExplodeFalseArrayStringWithHttpInfo(@javax.annotation.Nullable List queryObject, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeFalseArrayStringRequestBuilder(queryObject, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -726,7 +927,7 @@ public ApiResponse testQueryStyleFormExplodeFalseArrayStringWithHttpInfo } } - private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayStringRequestBuilder(@javax.annotation.Nullable List queryObject) throws ApiException { + private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayStringRequestBuilder(@javax.annotation.Nullable List queryObject, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -755,6 +956,8 @@ private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayStringRequestBuil if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -769,7 +972,19 @@ private HttpRequest.Builder testQueryStyleFormExplodeFalseArrayStringRequestBuil * @throws ApiException if fails to make API call */ public String testQueryStyleFormExplodeTrueArrayString(@javax.annotation.Nullable TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter queryObject) throws ApiException { - ApiResponse localVarResponse = testQueryStyleFormExplodeTrueArrayStringWithHttpInfo(queryObject); + return testQueryStyleFormExplodeTrueArrayString(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleFormExplodeTrueArrayString(@javax.annotation.Nullable TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter queryObject, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryStyleFormExplodeTrueArrayStringWithHttpInfo(queryObject, headers); return localVarResponse.getData(); } @@ -781,7 +996,19 @@ public String testQueryStyleFormExplodeTrueArrayString(@javax.annotation.Nullabl * @throws ApiException if fails to make API call */ public ApiResponse testQueryStyleFormExplodeTrueArrayStringWithHttpInfo(@javax.annotation.Nullable TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter queryObject) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeTrueArrayStringRequestBuilder(queryObject); + return testQueryStyleFormExplodeTrueArrayStringWithHttpInfo(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleFormExplodeTrueArrayStringWithHttpInfo(@javax.annotation.Nullable TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter queryObject, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeTrueArrayStringRequestBuilder(queryObject, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -817,7 +1044,7 @@ public ApiResponse testQueryStyleFormExplodeTrueArrayStringWithHttpInfo( } } - private HttpRequest.Builder testQueryStyleFormExplodeTrueArrayStringRequestBuilder(@javax.annotation.Nullable TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter queryObject) throws ApiException { + private HttpRequest.Builder testQueryStyleFormExplodeTrueArrayStringRequestBuilder(@javax.annotation.Nullable TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter queryObject, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -846,6 +1073,8 @@ private HttpRequest.Builder testQueryStyleFormExplodeTrueArrayStringRequestBuild if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -860,7 +1089,19 @@ private HttpRequest.Builder testQueryStyleFormExplodeTrueArrayStringRequestBuild * @throws ApiException if fails to make API call */ public String testQueryStyleFormExplodeTrueObject(@javax.annotation.Nullable Pet queryObject) throws ApiException { - ApiResponse localVarResponse = testQueryStyleFormExplodeTrueObjectWithHttpInfo(queryObject); + return testQueryStyleFormExplodeTrueObject(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleFormExplodeTrueObject(@javax.annotation.Nullable Pet queryObject, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryStyleFormExplodeTrueObjectWithHttpInfo(queryObject, headers); return localVarResponse.getData(); } @@ -872,7 +1113,19 @@ public String testQueryStyleFormExplodeTrueObject(@javax.annotation.Nullable Pet * @throws ApiException if fails to make API call */ public ApiResponse testQueryStyleFormExplodeTrueObjectWithHttpInfo(@javax.annotation.Nullable Pet queryObject) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeTrueObjectRequestBuilder(queryObject); + return testQueryStyleFormExplodeTrueObjectWithHttpInfo(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleFormExplodeTrueObjectWithHttpInfo(@javax.annotation.Nullable Pet queryObject, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeTrueObjectRequestBuilder(queryObject, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -908,7 +1161,7 @@ public ApiResponse testQueryStyleFormExplodeTrueObjectWithHttpInfo(@java } } - private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectRequestBuilder(@javax.annotation.Nullable Pet queryObject) throws ApiException { + private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectRequestBuilder(@javax.annotation.Nullable Pet queryObject, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -942,6 +1195,8 @@ private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectRequestBuilder(@j if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -956,7 +1211,19 @@ private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectRequestBuilder(@j * @throws ApiException if fails to make API call */ public String testQueryStyleFormExplodeTrueObjectAllOf(@javax.annotation.Nullable DataQuery queryObject) throws ApiException { - ApiResponse localVarResponse = testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(queryObject); + return testQueryStyleFormExplodeTrueObjectAllOf(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleFormExplodeTrueObjectAllOf(@javax.annotation.Nullable DataQuery queryObject, Map headers) throws ApiException { + ApiResponse localVarResponse = testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(queryObject, headers); return localVarResponse.getData(); } @@ -968,7 +1235,19 @@ public String testQueryStyleFormExplodeTrueObjectAllOf(@javax.annotation.Nullabl * @throws ApiException if fails to make API call */ public ApiResponse testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(@javax.annotation.Nullable DataQuery queryObject) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeTrueObjectAllOfRequestBuilder(queryObject); + return testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(queryObject, null); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(@javax.annotation.Nullable DataQuery queryObject, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeTrueObjectAllOfRequestBuilder(queryObject, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1004,7 +1283,7 @@ public ApiResponse testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo( } } - private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectAllOfRequestBuilder(@javax.annotation.Nullable DataQuery queryObject) throws ApiException { + private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectAllOfRequestBuilder(@javax.annotation.Nullable DataQuery queryObject, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1033,6 +1312,8 @@ private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectAllOfRequestBuild if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 1919d1809c23..b3a206650a1f 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -49,6 +49,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class AnotherFakeApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -71,6 +81,7 @@ public AnotherFakeApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + private ApiException getApiException(String operationId, HttpResponse response) { String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); return new ApiException(response.statusCode(), message, response.headers(), response.body()); @@ -91,8 +102,20 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public CompletableFuture call123testSpecialTags(@javax.annotation.Nonnull Client client) throws ApiException { + return call123testSpecialTags(client, null); + } + + /** + * To test special tags + * To test special tags and operation ID starting with number + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Client> + * @throws ApiException if fails to make API call + */ + public CompletableFuture call123testSpecialTags(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = call123testSpecialTagsRequestBuilder(client); + HttpRequest.Builder localVarRequestBuilder = call123testSpecialTagsRequestBuilder(client, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -122,8 +145,20 @@ public CompletableFuture call123testSpecialTags(@javax.annotation.Nonnul * @throws ApiException if fails to make API call */ public CompletableFuture> call123testSpecialTagsWithHttpInfo(@javax.annotation.Nonnull Client client) throws ApiException { + return call123testSpecialTagsWithHttpInfo(client, null); + } + + /** + * To test special tags + * To test special tags and operation ID starting with number + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Client>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> call123testSpecialTagsWithHttpInfo(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = call123testSpecialTagsRequestBuilder(client); + HttpRequest.Builder localVarRequestBuilder = call123testSpecialTagsRequestBuilder(client, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -152,7 +187,7 @@ public CompletableFuture> call123testSpecialTagsWithHttpInfo } } - private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotation.Nonnull Client client) throws ApiException { + private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { // verify the required parameter 'client' is set if (client == null) { throw new ApiException(400, "Missing the required parameter 'client' when calling call123testSpecialTags"); @@ -176,6 +211,8 @@ private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java index 761019e6d171..2c29e4ee6d65 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -49,6 +49,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class DefaultApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -71,6 +81,7 @@ public DefaultApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + private ApiException getApiException(String operationId, HttpResponse response) { String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); return new ApiException(response.statusCode(), message, response.headers(), response.body()); @@ -90,8 +101,19 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public CompletableFuture fooGet() throws ApiException { + return fooGet(null); + } + + /** + * + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<FooGetDefaultResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture fooGet(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fooGetRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = fooGetRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -120,8 +142,19 @@ public CompletableFuture fooGet() throws ApiException { * @throws ApiException if fails to make API call */ public CompletableFuture> fooGetWithHttpInfo() throws ApiException { + return fooGetWithHttpInfo(null); + } + + /** + * + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<FooGetDefaultResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> fooGetWithHttpInfo(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fooGetRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = fooGetRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -150,7 +183,7 @@ public CompletableFuture> fooGetWithHttpInfo( } } - private HttpRequest.Builder fooGetRequestBuilder() throws ApiException { + private HttpRequest.Builder fooGetRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -164,6 +197,8 @@ private HttpRequest.Builder fooGetRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java index d91496aa76de..770168b2fa80 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java @@ -66,6 +66,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class FakeApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -88,6 +98,7 @@ public FakeApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + private ApiException getApiException(String operationId, HttpResponse response) { String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); return new ApiException(response.statusCode(), message, response.headers(), response.body()); @@ -107,8 +118,19 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public CompletableFuture fakeBigDecimalMap() throws ApiException { + return fakeBigDecimalMap(null); + } + + /** + * + * for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys + * @param headers Optional headers to include in the request + * @return CompletableFuture<FakeBigDecimalMap200Response> + * @throws ApiException if fails to make API call + */ + public CompletableFuture fakeBigDecimalMap(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -137,8 +159,19 @@ public CompletableFuture fakeBigDecimalMap() throw * @throws ApiException if fails to make API call */ public CompletableFuture> fakeBigDecimalMapWithHttpInfo() throws ApiException { + return fakeBigDecimalMapWithHttpInfo(null); + } + + /** + * + * for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<FakeBigDecimalMap200Response>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> fakeBigDecimalMapWithHttpInfo(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -167,7 +200,7 @@ public CompletableFuture> fakeBigDecim } } - private HttpRequest.Builder fakeBigDecimalMapRequestBuilder() throws ApiException { + private HttpRequest.Builder fakeBigDecimalMapRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -181,6 +214,8 @@ private HttpRequest.Builder fakeBigDecimalMapRequestBuilder() throws ApiExceptio if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -194,8 +229,19 @@ private HttpRequest.Builder fakeBigDecimalMapRequestBuilder() throws ApiExceptio * @throws ApiException if fails to make API call */ public CompletableFuture fakeHealthGet() throws ApiException { + return fakeHealthGet(null); + } + + /** + * Health check endpoint + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<HealthCheckResult> + * @throws ApiException if fails to make API call + */ + public CompletableFuture fakeHealthGet(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeHealthGetRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = fakeHealthGetRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -224,8 +270,19 @@ public CompletableFuture fakeHealthGet() throws ApiException * @throws ApiException if fails to make API call */ public CompletableFuture> fakeHealthGetWithHttpInfo() throws ApiException { + return fakeHealthGetWithHttpInfo(null); + } + + /** + * Health check endpoint + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<HealthCheckResult>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> fakeHealthGetWithHttpInfo(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeHealthGetRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = fakeHealthGetRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -254,7 +311,7 @@ public CompletableFuture> fakeHealthGetWithHttpIn } } - private HttpRequest.Builder fakeHealthGetRequestBuilder() throws ApiException { + private HttpRequest.Builder fakeHealthGetRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -268,6 +325,8 @@ private HttpRequest.Builder fakeHealthGetRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -282,8 +341,20 @@ private HttpRequest.Builder fakeHealthGetRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public CompletableFuture fakeOuterBooleanSerialize(@javax.annotation.Nullable Boolean body) throws ApiException { + return fakeOuterBooleanSerialize(body, null); + } + + /** + * + * Test serialization of outer boolean types + * @param body Input boolean as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Boolean> + * @throws ApiException if fails to make API call + */ + public CompletableFuture fakeOuterBooleanSerialize(@javax.annotation.Nullable Boolean body, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterBooleanSerializeRequestBuilder(body); + HttpRequest.Builder localVarRequestBuilder = fakeOuterBooleanSerializeRequestBuilder(body, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -313,8 +384,20 @@ public CompletableFuture fakeOuterBooleanSerialize(@javax.annotation.Nu * @throws ApiException if fails to make API call */ public CompletableFuture> fakeOuterBooleanSerializeWithHttpInfo(@javax.annotation.Nullable Boolean body) throws ApiException { + return fakeOuterBooleanSerializeWithHttpInfo(body, null); + } + + /** + * + * Test serialization of outer boolean types + * @param body Input boolean as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Boolean>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> fakeOuterBooleanSerializeWithHttpInfo(@javax.annotation.Nullable Boolean body, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterBooleanSerializeRequestBuilder(body); + HttpRequest.Builder localVarRequestBuilder = fakeOuterBooleanSerializeRequestBuilder(body, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -343,7 +426,7 @@ public CompletableFuture> fakeOuterBooleanSerializeWithHttp } } - private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annotation.Nullable Boolean body) throws ApiException { + private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annotation.Nullable Boolean body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -363,6 +446,8 @@ private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annot if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -377,8 +462,20 @@ private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annot * @throws ApiException if fails to make API call */ public CompletableFuture fakeOuterCompositeSerialize(@javax.annotation.Nullable OuterComposite outerComposite) throws ApiException { + return fakeOuterCompositeSerialize(outerComposite, null); + } + + /** + * + * Test serialization of object with outer number type + * @param outerComposite Input composite as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<OuterComposite> + * @throws ApiException if fails to make API call + */ + public CompletableFuture fakeOuterCompositeSerialize(@javax.annotation.Nullable OuterComposite outerComposite, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterCompositeSerializeRequestBuilder(outerComposite); + HttpRequest.Builder localVarRequestBuilder = fakeOuterCompositeSerializeRequestBuilder(outerComposite, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -408,8 +505,20 @@ public CompletableFuture fakeOuterCompositeSerialize(@javax.anno * @throws ApiException if fails to make API call */ public CompletableFuture> fakeOuterCompositeSerializeWithHttpInfo(@javax.annotation.Nullable OuterComposite outerComposite) throws ApiException { + return fakeOuterCompositeSerializeWithHttpInfo(outerComposite, null); + } + + /** + * + * Test serialization of object with outer number type + * @param outerComposite Input composite as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<OuterComposite>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> fakeOuterCompositeSerializeWithHttpInfo(@javax.annotation.Nullable OuterComposite outerComposite, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterCompositeSerializeRequestBuilder(outerComposite); + HttpRequest.Builder localVarRequestBuilder = fakeOuterCompositeSerializeRequestBuilder(outerComposite, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -438,7 +547,7 @@ public CompletableFuture> fakeOuterCompositeSerializ } } - private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.annotation.Nullable OuterComposite outerComposite) throws ApiException { + private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.annotation.Nullable OuterComposite outerComposite, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -458,6 +567,8 @@ private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.ann if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -472,8 +583,20 @@ private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.ann * @throws ApiException if fails to make API call */ public CompletableFuture fakeOuterNumberSerialize(@javax.annotation.Nullable BigDecimal body) throws ApiException { + return fakeOuterNumberSerialize(body, null); + } + + /** + * + * Test serialization of outer number types + * @param body Input number as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<BigDecimal> + * @throws ApiException if fails to make API call + */ + public CompletableFuture fakeOuterNumberSerialize(@javax.annotation.Nullable BigDecimal body, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterNumberSerializeRequestBuilder(body); + HttpRequest.Builder localVarRequestBuilder = fakeOuterNumberSerializeRequestBuilder(body, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -503,8 +626,20 @@ public CompletableFuture fakeOuterNumberSerialize(@javax.annotation. * @throws ApiException if fails to make API call */ public CompletableFuture> fakeOuterNumberSerializeWithHttpInfo(@javax.annotation.Nullable BigDecimal body) throws ApiException { + return fakeOuterNumberSerializeWithHttpInfo(body, null); + } + + /** + * + * Test serialization of outer number types + * @param body Input number as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<BigDecimal>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> fakeOuterNumberSerializeWithHttpInfo(@javax.annotation.Nullable BigDecimal body, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterNumberSerializeRequestBuilder(body); + HttpRequest.Builder localVarRequestBuilder = fakeOuterNumberSerializeRequestBuilder(body, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -533,7 +668,7 @@ public CompletableFuture> fakeOuterNumberSerializeWithHt } } - private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annotation.Nullable BigDecimal body) throws ApiException { + private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annotation.Nullable BigDecimal body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -553,6 +688,8 @@ private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annota if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -567,8 +704,20 @@ private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annota * @throws ApiException if fails to make API call */ public CompletableFuture fakeOuterStringSerialize(@javax.annotation.Nullable String body) throws ApiException { + return fakeOuterStringSerialize(body, null); + } + + /** + * + * Test serialization of outer string types + * @param body Input string as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<String> + * @throws ApiException if fails to make API call + */ + public CompletableFuture fakeOuterStringSerialize(@javax.annotation.Nullable String body, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterStringSerializeRequestBuilder(body); + HttpRequest.Builder localVarRequestBuilder = fakeOuterStringSerializeRequestBuilder(body, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -598,8 +747,20 @@ public CompletableFuture fakeOuterStringSerialize(@javax.annotation.Null * @throws ApiException if fails to make API call */ public CompletableFuture> fakeOuterStringSerializeWithHttpInfo(@javax.annotation.Nullable String body) throws ApiException { + return fakeOuterStringSerializeWithHttpInfo(body, null); + } + + /** + * + * Test serialization of outer string types + * @param body Input string as post body (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<String>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> fakeOuterStringSerializeWithHttpInfo(@javax.annotation.Nullable String body, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = fakeOuterStringSerializeRequestBuilder(body); + HttpRequest.Builder localVarRequestBuilder = fakeOuterStringSerializeRequestBuilder(body, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -628,7 +789,7 @@ public CompletableFuture> fakeOuterStringSerializeWithHttpIn } } - private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annotation.Nullable String body) throws ApiException { + private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annotation.Nullable String body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -643,6 +804,8 @@ private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annota if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -656,8 +819,19 @@ private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annota * @throws ApiException if fails to make API call */ public CompletableFuture> getApplicationJsonUtf8() throws ApiException { + return getApplicationJsonUtf8(null); + } + + /** + * application/json UTF8 + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<List<OuterEnum>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getApplicationJsonUtf8(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getApplicationJsonUtf8RequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = getApplicationJsonUtf8RequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -686,8 +860,19 @@ public CompletableFuture> getApplicationJsonUtf8() throws ApiExc * @throws ApiException if fails to make API call */ public CompletableFuture>> getApplicationJsonUtf8WithHttpInfo() throws ApiException { + return getApplicationJsonUtf8WithHttpInfo(null); + } + + /** + * application/json UTF8 + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<List<OuterEnum>>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture>> getApplicationJsonUtf8WithHttpInfo(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getApplicationJsonUtf8RequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = getApplicationJsonUtf8RequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -716,7 +901,7 @@ public CompletableFuture>> getApplicationJsonUtf8Wit } } - private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder() throws ApiException { + private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -730,6 +915,8 @@ private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder() throws ApiExc if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -743,8 +930,19 @@ private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder() throws ApiExc * @throws ApiException if fails to make API call */ public CompletableFuture> getArrayOfEnums() throws ApiException { + return getArrayOfEnums(null); + } + + /** + * Array of Enums + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<List<OuterEnum>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getArrayOfEnums(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getArrayOfEnumsRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = getArrayOfEnumsRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -773,8 +971,19 @@ public CompletableFuture> getArrayOfEnums() throws ApiException * @throws ApiException if fails to make API call */ public CompletableFuture>> getArrayOfEnumsWithHttpInfo() throws ApiException { + return getArrayOfEnumsWithHttpInfo(null); + } + + /** + * Array of Enums + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<List<OuterEnum>>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture>> getArrayOfEnumsWithHttpInfo(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getArrayOfEnumsRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = getArrayOfEnumsRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -803,7 +1012,7 @@ public CompletableFuture>> getArrayOfEnumsWithHttpIn } } - private HttpRequest.Builder getArrayOfEnumsRequestBuilder() throws ApiException { + private HttpRequest.Builder getArrayOfEnumsRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -817,6 +1026,8 @@ private HttpRequest.Builder getArrayOfEnumsRequestBuilder() throws ApiException if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -831,8 +1042,20 @@ private HttpRequest.Builder getArrayOfEnumsRequestBuilder() throws ApiException * @throws ApiException if fails to make API call */ public CompletableFuture testAdditionalPropertiesReference(@javax.annotation.Nonnull Map requestBody) throws ApiException { + return testAdditionalPropertiesReference(requestBody, null); + } + + /** + * test referenced additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testAdditionalPropertiesReference(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testAdditionalPropertiesReferenceRequestBuilder(requestBody); + HttpRequest.Builder localVarRequestBuilder = testAdditionalPropertiesReferenceRequestBuilder(requestBody, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -855,8 +1078,20 @@ public CompletableFuture testAdditionalPropertiesReference(@javax.annotati * @throws ApiException if fails to make API call */ public CompletableFuture> testAdditionalPropertiesReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody) throws ApiException { + return testAdditionalPropertiesReferenceWithHttpInfo(requestBody, null); + } + + /** + * test referenced additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testAdditionalPropertiesReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testAdditionalPropertiesReferenceRequestBuilder(requestBody); + HttpRequest.Builder localVarRequestBuilder = testAdditionalPropertiesReferenceRequestBuilder(requestBody, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -877,7 +1112,7 @@ public CompletableFuture> testAdditionalPropertiesReferenceWit } } - private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody) throws ApiException { + private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { // verify the required parameter 'requestBody' is set if (requestBody == null) { throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testAdditionalPropertiesReference"); @@ -901,6 +1136,8 @@ private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@jav if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -915,8 +1152,20 @@ private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@jav * @throws ApiException if fails to make API call */ public CompletableFuture testBodyWithFileSchema(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass) throws ApiException { + return testBodyWithFileSchema(fileSchemaTestClass, null); + } + + /** + * + * For this test, the body for this request much reference a schema named `File`. + * @param fileSchemaTestClass (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testBodyWithFileSchema(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testBodyWithFileSchemaRequestBuilder(fileSchemaTestClass); + HttpRequest.Builder localVarRequestBuilder = testBodyWithFileSchemaRequestBuilder(fileSchemaTestClass, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -939,8 +1188,20 @@ public CompletableFuture testBodyWithFileSchema(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public CompletableFuture> testBodyWithFileSchemaWithHttpInfo(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass) throws ApiException { + return testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass, null); + } + + /** + * + * For this test, the body for this request much reference a schema named `File`. + * @param fileSchemaTestClass (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testBodyWithFileSchemaWithHttpInfo(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testBodyWithFileSchemaRequestBuilder(fileSchemaTestClass); + HttpRequest.Builder localVarRequestBuilder = testBodyWithFileSchemaRequestBuilder(fileSchemaTestClass, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -961,7 +1222,7 @@ public CompletableFuture> testBodyWithFileSchemaWithHttpInfo(@ } } - private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass) throws ApiException { + private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass, Map headers) throws ApiException { // verify the required parameter 'fileSchemaTestClass' is set if (fileSchemaTestClass == null) { throw new ApiException(400, "Missing the required parameter 'fileSchemaTestClass' when calling testBodyWithFileSchema"); @@ -985,6 +1246,8 @@ private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1000,8 +1263,21 @@ private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotati * @throws ApiException if fails to make API call */ public CompletableFuture testBodyWithQueryParams(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user) throws ApiException { + return testBodyWithQueryParams(query, user, null); + } + + /** + * + * + * @param query (required) + * @param user (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testBodyWithQueryParams(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testBodyWithQueryParamsRequestBuilder(query, user); + HttpRequest.Builder localVarRequestBuilder = testBodyWithQueryParamsRequestBuilder(query, user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1025,8 +1301,21 @@ public CompletableFuture testBodyWithQueryParams(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public CompletableFuture> testBodyWithQueryParamsWithHttpInfo(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user) throws ApiException { + return testBodyWithQueryParamsWithHttpInfo(query, user, null); + } + + /** + * + * + * @param query (required) + * @param user (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testBodyWithQueryParamsWithHttpInfo(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testBodyWithQueryParamsRequestBuilder(query, user); + HttpRequest.Builder localVarRequestBuilder = testBodyWithQueryParamsRequestBuilder(query, user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1047,7 +1336,7 @@ public CompletableFuture> testBodyWithQueryParamsWithHttpInfo( } } - private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'query' is set if (query == null) { throw new ApiException(400, "Missing the required parameter 'query' when calling testBodyWithQueryParams"); @@ -1090,6 +1379,8 @@ private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotat if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1104,8 +1395,20 @@ private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotat * @throws ApiException if fails to make API call */ public CompletableFuture testClientModel(@javax.annotation.Nonnull Client client) throws ApiException { + return testClientModel(client, null); + } + + /** + * To test \"client\" model + * To test \"client\" model + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Client> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testClientModel(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testClientModelRequestBuilder(client); + HttpRequest.Builder localVarRequestBuilder = testClientModelRequestBuilder(client, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1135,8 +1438,20 @@ public CompletableFuture testClientModel(@javax.annotation.Nonnull Clien * @throws ApiException if fails to make API call */ public CompletableFuture> testClientModelWithHttpInfo(@javax.annotation.Nonnull Client client) throws ApiException { + return testClientModelWithHttpInfo(client, null); + } + + /** + * To test \"client\" model + * To test \"client\" model + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Client>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testClientModelWithHttpInfo(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testClientModelRequestBuilder(client); + HttpRequest.Builder localVarRequestBuilder = testClientModelRequestBuilder(client, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1165,7 +1480,7 @@ public CompletableFuture> testClientModelWithHttpInfo(@javax } } - private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonnull Client client) throws ApiException { + private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { // verify the required parameter 'client' is set if (client == null) { throw new ApiException(400, "Missing the required parameter 'client' when calling testClientModel"); @@ -1189,6 +1504,8 @@ private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonn if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1216,8 +1533,33 @@ private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonn * @throws ApiException if fails to make API call */ public CompletableFuture testEndpointParameters(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) throws ApiException { + return testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null); + } + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional, default to 2010-02-01T10:20:10.111110+01:00) + * @param password None (optional) + * @param paramCallback None (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testEndpointParameters(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testEndpointParametersRequestBuilder(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + HttpRequest.Builder localVarRequestBuilder = testEndpointParametersRequestBuilder(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1253,8 +1595,33 @@ public CompletableFuture testEndpointParameters(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public CompletableFuture> testEndpointParametersWithHttpInfo(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) throws ApiException { + return testEndpointParametersWithHttpInfo(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null); + } + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional, default to 2010-02-01T10:20:10.111110+01:00) + * @param password None (optional) + * @param paramCallback None (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testEndpointParametersWithHttpInfo(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testEndpointParametersRequestBuilder(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + HttpRequest.Builder localVarRequestBuilder = testEndpointParametersRequestBuilder(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1275,7 +1642,7 @@ public CompletableFuture> testEndpointParametersWithHttpInfo(@ } } - private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) throws ApiException { + private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback, Map headers) throws ApiException { // verify the required parameter 'number' is set if (number == null) { throw new ApiException(400, "Missing the required parameter 'number' when calling testEndpointParameters"); @@ -1358,6 +1725,8 @@ private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1379,8 +1748,27 @@ private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotati * @throws ApiException if fails to make API call */ public CompletableFuture testEnumParameters(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString) throws ApiException { + return testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null); + } + + /** + * To test enum parameters + * To test enum parameters + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testEnumParameters(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testEnumParametersRequestBuilder(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + HttpRequest.Builder localVarRequestBuilder = testEnumParametersRequestBuilder(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1410,8 +1798,27 @@ public CompletableFuture testEnumParameters(@javax.annotation.Nullable Lis * @throws ApiException if fails to make API call */ public CompletableFuture> testEnumParametersWithHttpInfo(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString) throws ApiException { + return testEnumParametersWithHttpInfo(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null); + } + + /** + * To test enum parameters + * To test enum parameters + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testEnumParametersWithHttpInfo(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testEnumParametersRequestBuilder(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + HttpRequest.Builder localVarRequestBuilder = testEnumParametersRequestBuilder(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1432,7 +1839,7 @@ public CompletableFuture> testEnumParametersWithHttpInfo(@java } } - private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString) throws ApiException { + private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1492,6 +1899,8 @@ private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.N if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1506,6 +1915,18 @@ private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.N * @throws ApiException if fails to make API call */ public CompletableFuture testGroupParameters(APITestGroupParametersRequest apiRequest) throws ApiException { + return testGroupParameters(apiRequest, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param apiRequest {@link APITestGroupParametersRequest} + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testGroupParameters(APITestGroupParametersRequest apiRequest, Map headers) throws ApiException { @javax.annotation.Nonnull Integer requiredStringGroup = apiRequest.requiredStringGroup(); @javax.annotation.Nonnull @@ -1518,7 +1939,7 @@ public CompletableFuture testGroupParameters(APITestGroupParametersRequest Boolean booleanGroup = apiRequest.booleanGroup(); @javax.annotation.Nullable Long int64Group = apiRequest.int64Group(); - return testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + return testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); } /** @@ -1529,13 +1950,25 @@ public CompletableFuture testGroupParameters(APITestGroupParametersRequest * @throws ApiException if fails to make API call */ public CompletableFuture> testGroupParametersWithHttpInfo(APITestGroupParametersRequest apiRequest) throws ApiException { + return testGroupParametersWithHttpInfo(apiRequest, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param apiRequest {@link APITestGroupParametersRequest} + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testGroupParametersWithHttpInfo(APITestGroupParametersRequest apiRequest, Map headers) throws ApiException { Integer requiredStringGroup = apiRequest.requiredStringGroup(); Boolean requiredBooleanGroup = apiRequest.requiredBooleanGroup(); Long requiredInt64Group = apiRequest.requiredInt64Group(); Integer stringGroup = apiRequest.stringGroup(); Boolean booleanGroup = apiRequest.booleanGroup(); Long int64Group = apiRequest.int64Group(); - return testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + return testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); } /** @@ -1551,8 +1984,25 @@ public CompletableFuture> testGroupParametersWithHttpInfo(APIT * @throws ApiException if fails to make API call */ public CompletableFuture testGroupParameters(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group) throws ApiException { + return testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testGroupParameters(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testGroupParametersRequestBuilder(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + HttpRequest.Builder localVarRequestBuilder = testGroupParametersRequestBuilder(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1580,8 +2030,25 @@ public CompletableFuture testGroupParameters(@javax.annotation.Nonnull Int * @throws ApiException if fails to make API call */ public CompletableFuture> testGroupParametersWithHttpInfo(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group) throws ApiException { + return testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testGroupParametersWithHttpInfo(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testGroupParametersRequestBuilder(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + HttpRequest.Builder localVarRequestBuilder = testGroupParametersRequestBuilder(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1602,7 +2069,7 @@ public CompletableFuture> testGroupParametersWithHttpInfo(@jav } } - private HttpRequest.Builder testGroupParametersRequestBuilder(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group) throws ApiException { + private HttpRequest.Builder testGroupParametersRequestBuilder(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group, Map headers) throws ApiException { // verify the required parameter 'requiredStringGroup' is set if (requiredStringGroup == null) { throw new ApiException(400, "Missing the required parameter 'requiredStringGroup' when calling testGroupParameters"); @@ -1655,6 +2122,8 @@ private HttpRequest.Builder testGroupParametersRequestBuilder(@javax.annotation. if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1758,8 +2227,20 @@ public APITestGroupParametersRequest build() { * @throws ApiException if fails to make API call */ public CompletableFuture testInlineAdditionalProperties(@javax.annotation.Nonnull Map requestBody) throws ApiException { + return testInlineAdditionalProperties(requestBody, null); + } + + /** + * test inline additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testInlineAdditionalProperties(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testInlineAdditionalPropertiesRequestBuilder(requestBody); + HttpRequest.Builder localVarRequestBuilder = testInlineAdditionalPropertiesRequestBuilder(requestBody, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1782,8 +2263,20 @@ public CompletableFuture testInlineAdditionalProperties(@javax.annotation. * @throws ApiException if fails to make API call */ public CompletableFuture> testInlineAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull Map requestBody) throws ApiException { + return testInlineAdditionalPropertiesWithHttpInfo(requestBody, null); + } + + /** + * test inline additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testInlineAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testInlineAdditionalPropertiesRequestBuilder(requestBody); + HttpRequest.Builder localVarRequestBuilder = testInlineAdditionalPropertiesRequestBuilder(requestBody, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1804,7 +2297,7 @@ public CompletableFuture> testInlineAdditionalPropertiesWithHt } } - private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull Map requestBody) throws ApiException { + private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { // verify the required parameter 'requestBody' is set if (requestBody == null) { throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testInlineAdditionalProperties"); @@ -1828,6 +2321,8 @@ private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax. if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1842,8 +2337,20 @@ private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax. * @throws ApiException if fails to make API call */ public CompletableFuture testInlineFreeformAdditionalProperties(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) throws ApiException { + return testInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest, null); + } + + /** + * test inline free-form additionalProperties + * + * @param testInlineFreeformAdditionalPropertiesRequest request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testInlineFreeformAdditionalProperties(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testInlineFreeformAdditionalPropertiesRequestBuilder(testInlineFreeformAdditionalPropertiesRequest); + HttpRequest.Builder localVarRequestBuilder = testInlineFreeformAdditionalPropertiesRequestBuilder(testInlineFreeformAdditionalPropertiesRequest, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1866,8 +2373,20 @@ public CompletableFuture testInlineFreeformAdditionalProperties(@javax.ann * @throws ApiException if fails to make API call */ public CompletableFuture> testInlineFreeformAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) throws ApiException { + return testInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest, null); + } + + /** + * test inline free-form additionalProperties + * + * @param testInlineFreeformAdditionalPropertiesRequest request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testInlineFreeformAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testInlineFreeformAdditionalPropertiesRequestBuilder(testInlineFreeformAdditionalPropertiesRequest); + HttpRequest.Builder localVarRequestBuilder = testInlineFreeformAdditionalPropertiesRequestBuilder(testInlineFreeformAdditionalPropertiesRequest, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1888,7 +2407,7 @@ public CompletableFuture> testInlineFreeformAdditionalProperti } } - private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) throws ApiException { + private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, Map headers) throws ApiException { // verify the required parameter 'testInlineFreeformAdditionalPropertiesRequest' is set if (testInlineFreeformAdditionalPropertiesRequest == null) { throw new ApiException(400, "Missing the required parameter 'testInlineFreeformAdditionalPropertiesRequest' when calling testInlineFreeformAdditionalProperties"); @@ -1912,6 +2431,8 @@ private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1927,8 +2448,21 @@ private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder * @throws ApiException if fails to make API call */ public CompletableFuture testJsonFormData(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2) throws ApiException { + return testJsonFormData(param, param2, null); + } + + /** + * test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testJsonFormData(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testJsonFormDataRequestBuilder(param, param2); + HttpRequest.Builder localVarRequestBuilder = testJsonFormDataRequestBuilder(param, param2, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1952,8 +2486,21 @@ public CompletableFuture testJsonFormData(@javax.annotation.Nonnull String * @throws ApiException if fails to make API call */ public CompletableFuture> testJsonFormDataWithHttpInfo(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2) throws ApiException { + return testJsonFormDataWithHttpInfo(param, param2, null); + } + + /** + * test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testJsonFormDataWithHttpInfo(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testJsonFormDataRequestBuilder(param, param2); + HttpRequest.Builder localVarRequestBuilder = testJsonFormDataRequestBuilder(param, param2, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -1974,7 +2521,7 @@ public CompletableFuture> testJsonFormDataWithHttpInfo(@javax. } } - private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2) throws ApiException { + private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Map headers) throws ApiException { // verify the required parameter 'param' is set if (param == null) { throw new ApiException(400, "Missing the required parameter 'param' when calling testJsonFormData"); @@ -2013,6 +2560,8 @@ private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Non if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -2031,8 +2580,24 @@ private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Non * @throws ApiException if fails to make API call */ public CompletableFuture testQueryParameterCollectionFormat(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context) throws ApiException { + return testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, null); + } + + /** + * + * To test the collection format in query parameters + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testQueryParameterCollectionFormat(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testQueryParameterCollectionFormatRequestBuilder(pipe, ioutil, http, url, context); + HttpRequest.Builder localVarRequestBuilder = testQueryParameterCollectionFormatRequestBuilder(pipe, ioutil, http, url, context, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -2059,8 +2624,24 @@ public CompletableFuture testQueryParameterCollectionFormat(@javax.annotat * @throws ApiException if fails to make API call */ public CompletableFuture> testQueryParameterCollectionFormatWithHttpInfo(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context) throws ApiException { + return testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, null); + } + + /** + * + * To test the collection format in query parameters + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testQueryParameterCollectionFormatWithHttpInfo(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testQueryParameterCollectionFormatRequestBuilder(pipe, ioutil, http, url, context); + HttpRequest.Builder localVarRequestBuilder = testQueryParameterCollectionFormatRequestBuilder(pipe, ioutil, http, url, context, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -2081,7 +2662,7 @@ public CompletableFuture> testQueryParameterCollectionFormatWi } } - private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context) throws ApiException { + private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context, Map headers) throws ApiException { // verify the required parameter 'pipe' is set if (pipe == null) { throw new ApiException(400, "Missing the required parameter 'pipe' when calling testQueryParameterCollectionFormat"); @@ -2138,6 +2719,8 @@ private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@ja if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -2152,8 +2735,20 @@ private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@ja * @throws ApiException if fails to make API call */ public CompletableFuture testStringMapReference(@javax.annotation.Nonnull Map requestBody) throws ApiException { + return testStringMapReference(requestBody, null); + } + + /** + * test referenced string map + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testStringMapReference(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody); + HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -2176,8 +2771,20 @@ public CompletableFuture testStringMapReference(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public CompletableFuture> testStringMapReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody) throws ApiException { + return testStringMapReferenceWithHttpInfo(requestBody, null); + } + + /** + * test referenced string map + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testStringMapReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody); + HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -2198,7 +2805,7 @@ public CompletableFuture> testStringMapReferenceWithHttpInfo(@ } } - private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody) throws ApiException { + private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { // verify the required parameter 'requestBody' is set if (requestBody == null) { throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testStringMapReference"); @@ -2222,6 +2829,8 @@ private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 50ba0a06562b..aca344a8a134 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -55,6 +55,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class FakeClassnameTags123Api { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -77,6 +87,7 @@ public FakeClassnameTags123Api(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + private ApiException getApiException(String operationId, HttpResponse response) { String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); return new ApiException(response.statusCode(), message, response.headers(), response.body()); @@ -97,8 +108,20 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public CompletableFuture testClassname(@javax.annotation.Nonnull Client client) throws ApiException { + return testClassname(client, null); + } + + /** + * To test class name in snake case + * To test class name in snake case + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Client> + * @throws ApiException if fails to make API call + */ + public CompletableFuture testClassname(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testClassnameRequestBuilder(client); + HttpRequest.Builder localVarRequestBuilder = testClassnameRequestBuilder(client, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -128,8 +151,20 @@ public CompletableFuture testClassname(@javax.annotation.Nonnull Client * @throws ApiException if fails to make API call */ public CompletableFuture> testClassnameWithHttpInfo(@javax.annotation.Nonnull Client client) throws ApiException { + return testClassnameWithHttpInfo(client, null); + } + + /** + * To test class name in snake case + * To test class name in snake case + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Client>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> testClassnameWithHttpInfo(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = testClassnameRequestBuilder(client); + HttpRequest.Builder localVarRequestBuilder = testClassnameRequestBuilder(client, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -158,7 +193,7 @@ public CompletableFuture> testClassnameWithHttpInfo(@javax.a } } - private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnull Client client) throws ApiException { + private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { // verify the required parameter 'client' is set if (client == null) { throw new ApiException(400, "Missing the required parameter 'client' when calling testClassname"); @@ -182,6 +217,8 @@ private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnul if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java index 0dea62269b82..4182c186e608 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java @@ -57,6 +57,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class PetApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -79,6 +89,7 @@ public PetApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + private ApiException getApiException(String operationId, HttpResponse response) { String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); return new ApiException(response.statusCode(), message, response.headers(), response.body()); @@ -99,8 +110,20 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public CompletableFuture addPet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPet(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture addPet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet); + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -123,8 +146,20 @@ public CompletableFuture addPet(@javax.annotation.Nonnull Pet pet) throws * @throws ApiException if fails to make API call */ public CompletableFuture> addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPetWithHttpInfo(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet); + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -145,7 +180,7 @@ public CompletableFuture> addPetWithHttpInfo(@javax.annotation } } - private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet) throws ApiException { + private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { // verify the required parameter 'pet' is set if (pet == null) { throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet"); @@ -169,6 +204,8 @@ private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet p if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -184,8 +221,21 @@ private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet p * @throws ApiException if fails to make API call */ public CompletableFuture deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePet(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey); + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -209,8 +259,21 @@ public CompletableFuture deletePet(@javax.annotation.Nonnull Long petId, @ * @throws ApiException if fails to make API call */ public CompletableFuture> deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePetWithHttpInfo(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey); + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -231,7 +294,7 @@ public CompletableFuture> deletePetWithHttpInfo(@javax.annotat } } - private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); @@ -253,6 +316,8 @@ private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Lo if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -267,8 +332,20 @@ private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Lo * @throws ApiException if fails to make API call */ public CompletableFuture> findPetsByStatus(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatus(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<List<Pet>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> findPetsByStatus(@javax.annotation.Nonnull List status, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status); + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -298,8 +375,20 @@ public CompletableFuture> findPetsByStatus(@javax.annotation.Nonnull L * @throws ApiException if fails to make API call */ public CompletableFuture>> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatusWithHttpInfo(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<List<Pet>>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture>> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status); + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -328,7 +417,7 @@ public CompletableFuture>> findPetsByStatusWithHttpInfo(@j } } - private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status) throws ApiException { + private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status, Map headers) throws ApiException { // verify the required parameter 'status' is set if (status == null) { throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); @@ -361,6 +450,8 @@ private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Non if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -377,8 +468,22 @@ private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Non */ @Deprecated public CompletableFuture> findPetsByTags(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTags(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public CompletableFuture> findPetsByTags(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags); + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -410,8 +515,22 @@ public CompletableFuture> findPetsByTags(@javax.annotation.Nonnull Lis */ @Deprecated public CompletableFuture>> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTagsWithHttpInfo(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<List<Pet>>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public CompletableFuture>> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags); + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -440,7 +559,7 @@ public CompletableFuture>> findPetsByTagsWithHttpInfo(@jav } } - private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags) throws ApiException { + private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { // verify the required parameter 'tags' is set if (tags == null) { throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); @@ -473,6 +592,8 @@ private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnu if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -487,8 +608,20 @@ private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnu * @throws ApiException if fails to make API call */ public CompletableFuture getPetById(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetById(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Pet> + * @throws ApiException if fails to make API call + */ + public CompletableFuture getPetById(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId); + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -518,8 +651,20 @@ public CompletableFuture getPetById(@javax.annotation.Nonnull Long petId) t * @throws ApiException if fails to make API call */ public CompletableFuture> getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetByIdWithHttpInfo(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Pet>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId); + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -548,7 +693,7 @@ public CompletableFuture> getPetByIdWithHttpInfo(@javax.annotat } } - private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId) throws ApiException { + private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); @@ -567,6 +712,8 @@ private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull L if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -581,8 +728,20 @@ private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull L * @throws ApiException if fails to make API call */ public CompletableFuture updatePet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePet(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture updatePet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet); + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -605,8 +764,20 @@ public CompletableFuture updatePet(@javax.annotation.Nonnull Pet pet) thro * @throws ApiException if fails to make API call */ public CompletableFuture> updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePetWithHttpInfo(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet); + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -627,7 +798,7 @@ public CompletableFuture> updatePetWithHttpInfo(@javax.annotat } } - private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet) throws ApiException { + private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { // verify the required parameter 'pet' is set if (pet == null) { throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"); @@ -651,6 +822,8 @@ private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pe if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -667,8 +840,22 @@ private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pe * @throws ApiException if fails to make API call */ public CompletableFuture updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithForm(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status); + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -693,8 +880,22 @@ public CompletableFuture updatePetWithForm(@javax.annotation.Nonnull Long * @throws ApiException if fails to make API call */ public CompletableFuture> updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithFormWithHttpInfo(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status); + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -715,7 +916,7 @@ public CompletableFuture> updatePetWithFormWithHttpInfo(@javax } } - private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); @@ -751,6 +952,8 @@ private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.No if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -767,8 +970,22 @@ private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.No * @throws ApiException if fails to make API call */ public CompletableFuture uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFile(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file); + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -800,8 +1017,22 @@ public CompletableFuture uploadFile(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public CompletableFuture> uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFileWithHttpInfo(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<ModelApiResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file); + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -830,7 +1061,7 @@ public CompletableFuture> uploadFileWithHttpInfo(@ } } - private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); @@ -885,6 +1116,8 @@ private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull L if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -901,8 +1134,22 @@ private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull L * @throws ApiException if fails to make API call */ public CompletableFuture uploadFileWithRequiredFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata) throws ApiException { + return uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, null); + } + + /** + * uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture uploadFileWithRequiredFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = uploadFileWithRequiredFileRequestBuilder(petId, requiredFile, additionalMetadata); + HttpRequest.Builder localVarRequestBuilder = uploadFileWithRequiredFileRequestBuilder(petId, requiredFile, additionalMetadata, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -934,8 +1181,22 @@ public CompletableFuture uploadFileWithRequiredFile(@javax.ann * @throws ApiException if fails to make API call */ public CompletableFuture> uploadFileWithRequiredFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata) throws ApiException { + return uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata, null); + } + + /** + * uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<ModelApiResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> uploadFileWithRequiredFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = uploadFileWithRequiredFileRequestBuilder(petId, requiredFile, additionalMetadata); + HttpRequest.Builder localVarRequestBuilder = uploadFileWithRequiredFileRequestBuilder(petId, requiredFile, additionalMetadata, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -964,7 +1225,7 @@ public CompletableFuture> uploadFileWithRequiredFi } } - private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata) throws ApiException { + private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); @@ -1023,6 +1284,8 @@ private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.anno if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java index 9250421fa1a8..65f4fb0aef45 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java @@ -55,6 +55,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class StoreApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -77,6 +87,7 @@ public StoreApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + private ApiException getApiException(String operationId, HttpResponse response) { String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); return new ApiException(response.statusCode(), message, response.headers(), response.body()); @@ -97,8 +108,20 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public CompletableFuture deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrder(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture deleteOrder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId); + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -121,8 +144,20 @@ public CompletableFuture deleteOrder(@javax.annotation.Nonnull String orde * @throws ApiException if fails to make API call */ public CompletableFuture> deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrderWithHttpInfo(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId); + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -143,7 +178,7 @@ public CompletableFuture> deleteOrderWithHttpInfo(@javax.annot } } - private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId) throws ApiException { + private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); @@ -162,6 +197,8 @@ private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -175,8 +212,19 @@ private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public CompletableFuture> getInventory() throws ApiException { + return getInventory(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return CompletableFuture<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getInventory(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -205,8 +253,19 @@ public CompletableFuture> getInventory() throws ApiExceptio * @throws ApiException if fails to make API call */ public CompletableFuture>> getInventoryWithHttpInfo() throws ApiException { + return getInventoryWithHttpInfo(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Map<String, Integer>>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture>> getInventoryWithHttpInfo(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -235,7 +294,7 @@ public CompletableFuture>> getInventoryWithHttp } } - private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { + private HttpRequest.Builder getInventoryRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -249,6 +308,8 @@ private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -263,8 +324,20 @@ private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public CompletableFuture getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderById(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Order> + * @throws ApiException if fails to make API call + */ + public CompletableFuture getOrderById(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId); + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -294,8 +367,20 @@ public CompletableFuture getOrderById(@javax.annotation.Nonnull Long orde * @throws ApiException if fails to make API call */ public CompletableFuture> getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderByIdWithHttpInfo(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Order>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId); + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -324,7 +409,7 @@ public CompletableFuture> getOrderByIdWithHttpInfo(@javax.ann } } - private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId) throws ApiException { + private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); @@ -343,6 +428,8 @@ private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -357,8 +444,20 @@ private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public CompletableFuture placeOrder(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrder(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Order> + * @throws ApiException if fails to make API call + */ + public CompletableFuture placeOrder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order); + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -388,8 +487,20 @@ public CompletableFuture placeOrder(@javax.annotation.Nonnull Order order * @throws ApiException if fails to make API call */ public CompletableFuture> placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrderWithHttpInfo(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Order>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order); + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -418,7 +529,7 @@ public CompletableFuture> placeOrderWithHttpInfo(@javax.annot } } - private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order) throws ApiException { + private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { // verify the required parameter 'order' is set if (order == null) { throw new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"); @@ -442,6 +553,8 @@ private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull O if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java index f30354c274ec..9798f11648e5 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java @@ -56,6 +56,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class UserApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -78,6 +88,7 @@ public UserApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + private ApiException getApiException(String operationId, HttpResponse response) { String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); return new ApiException(response.statusCode(), message, response.headers(), response.body()); @@ -98,8 +109,20 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public CompletableFuture createUser(@javax.annotation.Nonnull User user) throws ApiException { + return createUser(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture createUser(@javax.annotation.Nonnull User user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user); + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -122,8 +145,20 @@ public CompletableFuture createUser(@javax.annotation.Nonnull User user) t * @throws ApiException if fails to make API call */ public CompletableFuture> createUserWithHttpInfo(@javax.annotation.Nonnull User user) throws ApiException { + return createUserWithHttpInfo(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> createUserWithHttpInfo(@javax.annotation.Nonnull User user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user); + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -144,7 +179,7 @@ public CompletableFuture> createUserWithHttpInfo(@javax.annota } } - private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUser"); @@ -168,6 +203,8 @@ private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull U if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -182,8 +219,20 @@ private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull U * @throws ApiException if fails to make API call */ public CompletableFuture createUsersWithArrayInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture createUsersWithArrayInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user); + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -206,8 +255,20 @@ public CompletableFuture createUsersWithArrayInput(@javax.annotation.Nonnu * @throws ApiException if fails to make API call */ public CompletableFuture> createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user); + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -228,7 +289,7 @@ public CompletableFuture> createUsersWithArrayInputWithHttpInf } } - private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user) throws ApiException { + private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"); @@ -252,6 +313,8 @@ private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annot if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -266,8 +329,20 @@ private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annot * @throws ApiException if fails to make API call */ public CompletableFuture createUsersWithListInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture createUsersWithListInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user); + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -290,8 +365,20 @@ public CompletableFuture createUsersWithListInput(@javax.annotation.Nonnul * @throws ApiException if fails to make API call */ public CompletableFuture> createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user); + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -312,7 +399,7 @@ public CompletableFuture> createUsersWithListInputWithHttpInfo } } - private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user) throws ApiException { + private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"); @@ -336,6 +423,8 @@ private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annota if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -350,8 +439,20 @@ private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annota * @throws ApiException if fails to make API call */ public CompletableFuture deleteUser(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUser(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture deleteUser(@javax.annotation.Nonnull String username, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username); + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -374,8 +475,20 @@ public CompletableFuture deleteUser(@javax.annotation.Nonnull String usern * @throws ApiException if fails to make API call */ public CompletableFuture> deleteUserWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUserWithHttpInfo(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> deleteUserWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username); + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -396,7 +509,7 @@ public CompletableFuture> deleteUserWithHttpInfo(@javax.annota } } - private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username) throws ApiException { + private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); @@ -415,6 +528,8 @@ private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull S if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -429,8 +544,20 @@ private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull S * @throws ApiException if fails to make API call */ public CompletableFuture getUserByName(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByName(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<User> + * @throws ApiException if fails to make API call + */ + public CompletableFuture getUserByName(@javax.annotation.Nonnull String username, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username); + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -460,8 +587,20 @@ public CompletableFuture getUserByName(@javax.annotation.Nonnull String us * @throws ApiException if fails to make API call */ public CompletableFuture> getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByNameWithHttpInfo(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<User>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username); + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -490,7 +629,7 @@ public CompletableFuture> getUserByNameWithHttpInfo(@javax.ann } } - private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username) throws ApiException { + private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); @@ -509,6 +648,8 @@ private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnul if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -524,8 +665,21 @@ private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnul * @throws ApiException if fails to make API call */ public CompletableFuture loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUser(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<String> + * @throws ApiException if fails to make API call + */ + public CompletableFuture loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password); + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -556,8 +710,21 @@ public CompletableFuture loginUser(@javax.annotation.Nonnull String user * @throws ApiException if fails to make API call */ public CompletableFuture> loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUserWithHttpInfo(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<String>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password); + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -586,7 +753,7 @@ public CompletableFuture> loginUserWithHttpInfo(@javax.annot } } - private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); @@ -625,6 +792,8 @@ private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull St if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -638,8 +807,19 @@ private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull St * @throws ApiException if fails to make API call */ public CompletableFuture logoutUser() throws ApiException { + return logoutUser(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture logoutUser(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -661,8 +841,19 @@ public CompletableFuture logoutUser() throws ApiException { * @throws ApiException if fails to make API call */ public CompletableFuture> logoutUserWithHttpInfo() throws ApiException { + return logoutUserWithHttpInfo(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> logoutUserWithHttpInfo(Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(); + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -683,7 +874,7 @@ public CompletableFuture> logoutUserWithHttpInfo() throws ApiE } } - private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { + private HttpRequest.Builder logoutUserRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -697,6 +888,8 @@ private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -712,8 +905,21 @@ private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public CompletableFuture updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUser(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user); + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -737,8 +943,21 @@ public CompletableFuture updateUser(@javax.annotation.Nonnull String usern * @throws ApiException if fails to make API call */ public CompletableFuture> updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUserWithHttpInfo(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { try { - HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user); + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { @@ -759,7 +978,7 @@ public CompletableFuture> updateUserWithHttpInfo(@javax.annota } } - private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); @@ -788,6 +1007,8 @@ private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull S if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java index c1706f368014..444fd255de3b 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java @@ -55,6 +55,16 @@ @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class PetApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -77,6 +87,7 @@ public PetApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -98,7 +109,19 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public Pet addPet(@jakarta.annotation.Nonnull Pet pet) throws ApiException { - ApiResponse localVarResponse = addPetWithHttpInfo(pet); + return addPet(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@jakarta.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = addPetWithHttpInfo(pet, headers); return localVarResponse.getData(); } @@ -110,7 +133,19 @@ public Pet addPet(@jakarta.annotation.Nonnull Pet pet) throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse addPetWithHttpInfo(@jakarta.annotation.Nonnull Pet pet) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet); + return addPetWithHttpInfo(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@jakarta.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -149,7 +184,7 @@ public ApiResponse addPetWithHttpInfo(@jakarta.annotation.Nonnull Pet pet) } } - private HttpRequest.Builder addPetRequestBuilder(@jakarta.annotation.Nonnull Pet pet) throws ApiException { + private HttpRequest.Builder addPetRequestBuilder(@jakarta.annotation.Nonnull Pet pet, Map headers) throws ApiException { // verify the required parameter 'pet' is set if (pet == null) { throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet"); @@ -173,6 +208,8 @@ private HttpRequest.Builder addPetRequestBuilder(@jakarta.annotation.Nonnull Pet if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -187,7 +224,19 @@ private HttpRequest.Builder addPetRequestBuilder(@jakarta.annotation.Nonnull Pet * @throws ApiException if fails to make API call */ public void deletePet(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String apiKey) throws ApiException { - deletePetWithHttpInfo(petId, apiKey); + deletePet(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deletePet(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String apiKey, Map headers) throws ApiException { + deletePetWithHttpInfo(petId, apiKey, headers); } /** @@ -199,7 +248,20 @@ public void deletePet(@jakarta.annotation.Nonnull Long petId, @jakarta.annotatio * @throws ApiException if fails to make API call */ public ApiResponse deletePetWithHttpInfo(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String apiKey) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey); + return deletePetWithHttpInfo(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String apiKey, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -232,7 +294,7 @@ public ApiResponse deletePetWithHttpInfo(@jakarta.annotation.Nonnull Long } } - private HttpRequest.Builder deletePetRequestBuilder(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String apiKey) throws ApiException { + private HttpRequest.Builder deletePetRequestBuilder(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String apiKey, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); @@ -254,6 +316,8 @@ private HttpRequest.Builder deletePetRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -268,7 +332,19 @@ private HttpRequest.Builder deletePetRequestBuilder(@jakarta.annotation.Nonnull * @throws ApiException if fails to make API call */ public List findPetsByStatus(@jakarta.annotation.Nonnull List status) throws ApiException { - ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status); + return findPetsByStatus(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@jakarta.annotation.Nonnull List status, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status, headers); return localVarResponse.getData(); } @@ -280,7 +356,19 @@ public List findPetsByStatus(@jakarta.annotation.Nonnull List statu * @throws ApiException if fails to make API call */ public ApiResponse> findPetsByStatusWithHttpInfo(@jakarta.annotation.Nonnull List status) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status); + return findPetsByStatusWithHttpInfo(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@jakarta.annotation.Nonnull List status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -319,7 +407,7 @@ public ApiResponse> findPetsByStatusWithHttpInfo(@jakarta.annotation.N } } - private HttpRequest.Builder findPetsByStatusRequestBuilder(@jakarta.annotation.Nonnull List status) throws ApiException { + private HttpRequest.Builder findPetsByStatusRequestBuilder(@jakarta.annotation.Nonnull List status, Map headers) throws ApiException { // verify the required parameter 'status' is set if (status == null) { throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); @@ -352,6 +440,8 @@ private HttpRequest.Builder findPetsByStatusRequestBuilder(@jakarta.annotation.N if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -368,7 +458,21 @@ private HttpRequest.Builder findPetsByStatusRequestBuilder(@jakarta.annotation.N */ @Deprecated public List findPetsByTags(@jakarta.annotation.Nonnull List tags) throws ApiException { - ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags); + return findPetsByTags(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@jakarta.annotation.Nonnull List tags, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags, headers); return localVarResponse.getData(); } @@ -382,7 +486,21 @@ public List findPetsByTags(@jakarta.annotation.Nonnull List tags) t */ @Deprecated public ApiResponse> findPetsByTagsWithHttpInfo(@jakarta.annotation.Nonnull List tags) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags); + return findPetsByTagsWithHttpInfo(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@jakarta.annotation.Nonnull List tags, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -421,7 +539,7 @@ public ApiResponse> findPetsByTagsWithHttpInfo(@jakarta.annotation.Non } } - private HttpRequest.Builder findPetsByTagsRequestBuilder(@jakarta.annotation.Nonnull List tags) throws ApiException { + private HttpRequest.Builder findPetsByTagsRequestBuilder(@jakarta.annotation.Nonnull List tags, Map headers) throws ApiException { // verify the required parameter 'tags' is set if (tags == null) { throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); @@ -454,6 +572,8 @@ private HttpRequest.Builder findPetsByTagsRequestBuilder(@jakarta.annotation.Non if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -468,7 +588,19 @@ private HttpRequest.Builder findPetsByTagsRequestBuilder(@jakarta.annotation.Non * @throws ApiException if fails to make API call */ public Pet getPetById(@jakarta.annotation.Nonnull Long petId) throws ApiException { - ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId); + return getPetById(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@jakarta.annotation.Nonnull Long petId, Map headers) throws ApiException { + ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId, headers); return localVarResponse.getData(); } @@ -480,7 +612,19 @@ public Pet getPetById(@jakarta.annotation.Nonnull Long petId) throws ApiExceptio * @throws ApiException if fails to make API call */ public ApiResponse getPetByIdWithHttpInfo(@jakarta.annotation.Nonnull Long petId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId); + return getPetByIdWithHttpInfo(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@jakarta.annotation.Nonnull Long petId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -519,7 +663,7 @@ public ApiResponse getPetByIdWithHttpInfo(@jakarta.annotation.Nonnull Long } } - private HttpRequest.Builder getPetByIdRequestBuilder(@jakarta.annotation.Nonnull Long petId) throws ApiException { + private HttpRequest.Builder getPetByIdRequestBuilder(@jakarta.annotation.Nonnull Long petId, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); @@ -538,6 +682,8 @@ private HttpRequest.Builder getPetByIdRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -554,7 +700,21 @@ private HttpRequest.Builder getPetByIdRequestBuilder(@jakarta.annotation.Nonnull * @see Update an existing pet Documentation */ public Pet updatePet(@jakarta.annotation.Nonnull Pet pet) throws ApiException { - ApiResponse localVarResponse = updatePetWithHttpInfo(pet); + return updatePet(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + * API documentation for the updatePet operation + * @see Update an existing pet Documentation + */ + public Pet updatePet(@jakarta.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = updatePetWithHttpInfo(pet, headers); return localVarResponse.getData(); } @@ -568,7 +728,21 @@ public Pet updatePet(@jakarta.annotation.Nonnull Pet pet) throws ApiException { * @see Update an existing pet Documentation */ public ApiResponse updatePetWithHttpInfo(@jakarta.annotation.Nonnull Pet pet) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet); + return updatePetWithHttpInfo(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + * API documentation for the updatePet operation + * @see Update an existing pet Documentation + */ + public ApiResponse updatePetWithHttpInfo(@jakarta.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -607,7 +781,7 @@ public ApiResponse updatePetWithHttpInfo(@jakarta.annotation.Nonnull Pet pe } } - private HttpRequest.Builder updatePetRequestBuilder(@jakarta.annotation.Nonnull Pet pet) throws ApiException { + private HttpRequest.Builder updatePetRequestBuilder(@jakarta.annotation.Nonnull Pet pet, Map headers) throws ApiException { // verify the required parameter 'pet' is set if (pet == null) { throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"); @@ -631,6 +805,8 @@ private HttpRequest.Builder updatePetRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -646,7 +822,20 @@ private HttpRequest.Builder updatePetRequestBuilder(@jakarta.annotation.Nonnull * @throws ApiException if fails to make API call */ public void updatePetWithForm(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String name, @jakarta.annotation.Nullable String status) throws ApiException { - updatePetWithFormWithHttpInfo(petId, name, status); + updatePetWithForm(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String name, @jakarta.annotation.Nullable String status, Map headers) throws ApiException { + updatePetWithFormWithHttpInfo(petId, name, status, headers); } /** @@ -659,7 +848,21 @@ public void updatePetWithForm(@jakarta.annotation.Nonnull Long petId, @jakarta.a * @throws ApiException if fails to make API call */ public ApiResponse updatePetWithFormWithHttpInfo(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String name, @jakarta.annotation.Nullable String status) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status); + return updatePetWithFormWithHttpInfo(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String name, @jakarta.annotation.Nullable String status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -692,7 +895,7 @@ public ApiResponse updatePetWithFormWithHttpInfo(@jakarta.annotation.Nonnu } } - private HttpRequest.Builder updatePetWithFormRequestBuilder(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String name, @jakarta.annotation.Nullable String status) throws ApiException { + private HttpRequest.Builder updatePetWithFormRequestBuilder(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String name, @jakarta.annotation.Nullable String status, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); @@ -728,6 +931,8 @@ private HttpRequest.Builder updatePetWithFormRequestBuilder(@jakarta.annotation. if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -744,7 +949,21 @@ private HttpRequest.Builder updatePetWithFormRequestBuilder(@jakarta.annotation. * @throws ApiException if fails to make API call */ public ModelApiResponse uploadFile(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String additionalMetadata, @jakarta.annotation.Nullable File _file) throws ApiException { - ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file); + return uploadFile(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String additionalMetadata, @jakarta.annotation.Nullable File _file, Map headers) throws ApiException { + ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file, headers); return localVarResponse.getData(); } @@ -758,7 +977,21 @@ public ModelApiResponse uploadFile(@jakarta.annotation.Nonnull Long petId, @jaka * @throws ApiException if fails to make API call */ public ApiResponse uploadFileWithHttpInfo(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String additionalMetadata, @jakarta.annotation.Nullable File _file) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file); + return uploadFileWithHttpInfo(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String additionalMetadata, @jakarta.annotation.Nullable File _file, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -797,7 +1030,7 @@ public ApiResponse uploadFileWithHttpInfo(@jakarta.annotation. } } - private HttpRequest.Builder uploadFileRequestBuilder(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String additionalMetadata, @jakarta.annotation.Nullable File _file) throws ApiException { + private HttpRequest.Builder uploadFileRequestBuilder(@jakarta.annotation.Nonnull Long petId, @jakarta.annotation.Nullable String additionalMetadata, @jakarta.annotation.Nullable File _file, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); @@ -852,6 +1085,8 @@ private HttpRequest.Builder uploadFileRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java index bcf89d35d458..bf39d5c45641 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java @@ -53,6 +53,16 @@ @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class StoreApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -75,6 +85,7 @@ public StoreApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -95,7 +106,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public void deleteOrder(@jakarta.annotation.Nonnull String orderId) throws ApiException { - deleteOrderWithHttpInfo(orderId); + deleteOrder(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@jakarta.annotation.Nonnull String orderId, Map headers) throws ApiException { + deleteOrderWithHttpInfo(orderId, headers); } /** @@ -106,7 +128,19 @@ public void deleteOrder(@jakarta.annotation.Nonnull String orderId) throws ApiEx * @throws ApiException if fails to make API call */ public ApiResponse deleteOrderWithHttpInfo(@jakarta.annotation.Nonnull String orderId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId); + return deleteOrderWithHttpInfo(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@jakarta.annotation.Nonnull String orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -139,7 +173,7 @@ public ApiResponse deleteOrderWithHttpInfo(@jakarta.annotation.Nonnull Str } } - private HttpRequest.Builder deleteOrderRequestBuilder(@jakarta.annotation.Nonnull String orderId) throws ApiException { + private HttpRequest.Builder deleteOrderRequestBuilder(@jakarta.annotation.Nonnull String orderId, Map headers) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); @@ -158,6 +192,8 @@ private HttpRequest.Builder deleteOrderRequestBuilder(@jakarta.annotation.Nonnul if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -171,7 +207,18 @@ private HttpRequest.Builder deleteOrderRequestBuilder(@jakarta.annotation.Nonnul * @throws ApiException if fails to make API call */ public Map getInventory() throws ApiException { - ApiResponse> localVarResponse = getInventoryWithHttpInfo(); + return getInventory(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory(Map headers) throws ApiException { + ApiResponse> localVarResponse = getInventoryWithHttpInfo(headers); return localVarResponse.getData(); } @@ -182,7 +229,18 @@ public Map getInventory() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse> getInventoryWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(); + return getInventoryWithHttpInfo(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -221,7 +279,7 @@ public ApiResponse> getInventoryWithHttpInfo() throws ApiEx } } - private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { + private HttpRequest.Builder getInventoryRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -235,6 +293,8 @@ private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -249,7 +309,19 @@ private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public Order getOrderById(@jakarta.annotation.Nonnull Long orderId) throws ApiException { - ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId); + return getOrderById(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@jakarta.annotation.Nonnull Long orderId, Map headers) throws ApiException { + ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId, headers); return localVarResponse.getData(); } @@ -261,7 +333,19 @@ public Order getOrderById(@jakarta.annotation.Nonnull Long orderId) throws ApiEx * @throws ApiException if fails to make API call */ public ApiResponse getOrderByIdWithHttpInfo(@jakarta.annotation.Nonnull Long orderId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId); + return getOrderByIdWithHttpInfo(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@jakarta.annotation.Nonnull Long orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -300,7 +384,7 @@ public ApiResponse getOrderByIdWithHttpInfo(@jakarta.annotation.Nonnull L } } - private HttpRequest.Builder getOrderByIdRequestBuilder(@jakarta.annotation.Nonnull Long orderId) throws ApiException { + private HttpRequest.Builder getOrderByIdRequestBuilder(@jakarta.annotation.Nonnull Long orderId, Map headers) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); @@ -319,6 +403,8 @@ private HttpRequest.Builder getOrderByIdRequestBuilder(@jakarta.annotation.Nonnu if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -333,7 +419,19 @@ private HttpRequest.Builder getOrderByIdRequestBuilder(@jakarta.annotation.Nonnu * @throws ApiException if fails to make API call */ public Order placeOrder(@jakarta.annotation.Nonnull Order order) throws ApiException { - ApiResponse localVarResponse = placeOrderWithHttpInfo(order); + return placeOrder(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@jakarta.annotation.Nonnull Order order, Map headers) throws ApiException { + ApiResponse localVarResponse = placeOrderWithHttpInfo(order, headers); return localVarResponse.getData(); } @@ -345,7 +443,19 @@ public Order placeOrder(@jakarta.annotation.Nonnull Order order) throws ApiExcep * @throws ApiException if fails to make API call */ public ApiResponse placeOrderWithHttpInfo(@jakarta.annotation.Nonnull Order order) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order); + return placeOrderWithHttpInfo(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@jakarta.annotation.Nonnull Order order, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -384,7 +494,7 @@ public ApiResponse placeOrderWithHttpInfo(@jakarta.annotation.Nonnull Ord } } - private HttpRequest.Builder placeOrderRequestBuilder(@jakarta.annotation.Nonnull Order order) throws ApiException { + private HttpRequest.Builder placeOrderRequestBuilder(@jakarta.annotation.Nonnull Order order, Map headers) throws ApiException { // verify the required parameter 'order' is set if (order == null) { throw new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"); @@ -408,6 +518,8 @@ private HttpRequest.Builder placeOrderRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java index b147efbfb003..69865abf3acd 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java @@ -54,6 +54,16 @@ @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class UserApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -76,6 +86,7 @@ public UserApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -96,7 +107,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public void createUser(@jakarta.annotation.Nonnull User user) throws ApiException { - createUserWithHttpInfo(user); + createUser(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUser(@jakarta.annotation.Nonnull User user, Map headers) throws ApiException { + createUserWithHttpInfo(user, headers); } /** @@ -107,7 +129,19 @@ public void createUser(@jakarta.annotation.Nonnull User user) throws ApiExceptio * @throws ApiException if fails to make API call */ public ApiResponse createUserWithHttpInfo(@jakarta.annotation.Nonnull User user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user); + return createUserWithHttpInfo(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@jakarta.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -140,7 +174,7 @@ public ApiResponse createUserWithHttpInfo(@jakarta.annotation.Nonnull User } } - private HttpRequest.Builder createUserRequestBuilder(@jakarta.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder createUserRequestBuilder(@jakarta.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUser"); @@ -164,6 +198,8 @@ private HttpRequest.Builder createUserRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -177,7 +213,18 @@ private HttpRequest.Builder createUserRequestBuilder(@jakarta.annotation.Nonnull * @throws ApiException if fails to make API call */ public void createUsersWithArrayInput(@jakarta.annotation.Nonnull List user) throws ApiException { - createUsersWithArrayInputWithHttpInfo(user); + createUsersWithArrayInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@jakarta.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithArrayInputWithHttpInfo(user, headers); } /** @@ -188,7 +235,19 @@ public void createUsersWithArrayInput(@jakarta.annotation.Nonnull List use * @throws ApiException if fails to make API call */ public ApiResponse createUsersWithArrayInputWithHttpInfo(@jakarta.annotation.Nonnull List user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user); + return createUsersWithArrayInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@jakarta.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -221,7 +280,7 @@ public ApiResponse createUsersWithArrayInputWithHttpInfo(@jakarta.annotati } } - private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@jakarta.annotation.Nonnull List user) throws ApiException { + private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@jakarta.annotation.Nonnull List user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"); @@ -245,6 +304,8 @@ private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@jakarta.ann if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -258,7 +319,18 @@ private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@jakarta.ann * @throws ApiException if fails to make API call */ public void createUsersWithListInput(@jakarta.annotation.Nonnull List user) throws ApiException { - createUsersWithListInputWithHttpInfo(user); + createUsersWithListInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@jakarta.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithListInputWithHttpInfo(user, headers); } /** @@ -269,7 +341,19 @@ public void createUsersWithListInput(@jakarta.annotation.Nonnull List user * @throws ApiException if fails to make API call */ public ApiResponse createUsersWithListInputWithHttpInfo(@jakarta.annotation.Nonnull List user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user); + return createUsersWithListInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@jakarta.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -302,7 +386,7 @@ public ApiResponse createUsersWithListInputWithHttpInfo(@jakarta.annotatio } } - private HttpRequest.Builder createUsersWithListInputRequestBuilder(@jakarta.annotation.Nonnull List user) throws ApiException { + private HttpRequest.Builder createUsersWithListInputRequestBuilder(@jakarta.annotation.Nonnull List user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"); @@ -326,6 +410,8 @@ private HttpRequest.Builder createUsersWithListInputRequestBuilder(@jakarta.anno if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -339,7 +425,18 @@ private HttpRequest.Builder createUsersWithListInputRequestBuilder(@jakarta.anno * @throws ApiException if fails to make API call */ public void deleteUser(@jakarta.annotation.Nonnull String username) throws ApiException { - deleteUserWithHttpInfo(username); + deleteUser(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteUser(@jakarta.annotation.Nonnull String username, Map headers) throws ApiException { + deleteUserWithHttpInfo(username, headers); } /** @@ -350,7 +447,19 @@ public void deleteUser(@jakarta.annotation.Nonnull String username) throws ApiEx * @throws ApiException if fails to make API call */ public ApiResponse deleteUserWithHttpInfo(@jakarta.annotation.Nonnull String username) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username); + return deleteUserWithHttpInfo(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@jakarta.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -383,7 +492,7 @@ public ApiResponse deleteUserWithHttpInfo(@jakarta.annotation.Nonnull Stri } } - private HttpRequest.Builder deleteUserRequestBuilder(@jakarta.annotation.Nonnull String username) throws ApiException { + private HttpRequest.Builder deleteUserRequestBuilder(@jakarta.annotation.Nonnull String username, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); @@ -402,6 +511,8 @@ private HttpRequest.Builder deleteUserRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -416,7 +527,19 @@ private HttpRequest.Builder deleteUserRequestBuilder(@jakarta.annotation.Nonnull * @throws ApiException if fails to make API call */ public User getUserByName(@jakarta.annotation.Nonnull String username) throws ApiException { - ApiResponse localVarResponse = getUserByNameWithHttpInfo(username); + return getUserByName(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@jakarta.annotation.Nonnull String username, Map headers) throws ApiException { + ApiResponse localVarResponse = getUserByNameWithHttpInfo(username, headers); return localVarResponse.getData(); } @@ -428,7 +551,19 @@ public User getUserByName(@jakarta.annotation.Nonnull String username) throws Ap * @throws ApiException if fails to make API call */ public ApiResponse getUserByNameWithHttpInfo(@jakarta.annotation.Nonnull String username) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username); + return getUserByNameWithHttpInfo(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@jakarta.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -467,7 +602,7 @@ public ApiResponse getUserByNameWithHttpInfo(@jakarta.annotation.Nonnull S } } - private HttpRequest.Builder getUserByNameRequestBuilder(@jakarta.annotation.Nonnull String username) throws ApiException { + private HttpRequest.Builder getUserByNameRequestBuilder(@jakarta.annotation.Nonnull String username, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); @@ -486,6 +621,8 @@ private HttpRequest.Builder getUserByNameRequestBuilder(@jakarta.annotation.Nonn if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -501,7 +638,20 @@ private HttpRequest.Builder getUserByNameRequestBuilder(@jakarta.annotation.Nonn * @throws ApiException if fails to make API call */ public String loginUser(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull String password) throws ApiException { - ApiResponse localVarResponse = loginUserWithHttpInfo(username, password); + return loginUser(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull String password, Map headers) throws ApiException { + ApiResponse localVarResponse = loginUserWithHttpInfo(username, password, headers); return localVarResponse.getData(); } @@ -514,7 +664,20 @@ public String loginUser(@jakarta.annotation.Nonnull String username, @jakarta.an * @throws ApiException if fails to make API call */ public ApiResponse loginUserWithHttpInfo(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull String password) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password); + return loginUserWithHttpInfo(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull String password, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -553,7 +716,7 @@ public ApiResponse loginUserWithHttpInfo(@jakarta.annotation.Nonnull Str } } - private HttpRequest.Builder loginUserRequestBuilder(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull String password) throws ApiException { + private HttpRequest.Builder loginUserRequestBuilder(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull String password, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); @@ -592,6 +755,8 @@ private HttpRequest.Builder loginUserRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -604,7 +769,17 @@ private HttpRequest.Builder loginUserRequestBuilder(@jakarta.annotation.Nonnull * @throws ApiException if fails to make API call */ public void logoutUser() throws ApiException { - logoutUserWithHttpInfo(); + logoutUser(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void logoutUser(Map headers) throws ApiException { + logoutUserWithHttpInfo(headers); } /** @@ -614,7 +789,18 @@ public void logoutUser() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse logoutUserWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(); + return logoutUserWithHttpInfo(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -647,7 +833,7 @@ public ApiResponse logoutUserWithHttpInfo() throws ApiException { } } - private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { + private HttpRequest.Builder logoutUserRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -661,6 +847,8 @@ private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -675,7 +863,19 @@ private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public void updateUser(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull User user) throws ApiException { - updateUserWithHttpInfo(username, user); + updateUser(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updateUser(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull User user, Map headers) throws ApiException { + updateUserWithHttpInfo(username, user, headers); } /** @@ -687,7 +887,20 @@ public void updateUser(@jakarta.annotation.Nonnull String username, @jakarta.ann * @throws ApiException if fails to make API call */ public ApiResponse updateUserWithHttpInfo(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull User user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user); + return updateUserWithHttpInfo(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -720,7 +933,7 @@ public ApiResponse updateUserWithHttpInfo(@jakarta.annotation.Nonnull Stri } } - private HttpRequest.Builder updateUserRequestBuilder(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder updateUserRequestBuilder(@jakarta.annotation.Nonnull String username, @jakarta.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); @@ -749,6 +962,8 @@ private HttpRequest.Builder updateUserRequestBuilder(@jakarta.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index ff0797c5a0c6..14ca8ecad778 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -47,6 +47,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class AnotherFakeApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -69,6 +79,7 @@ public AnotherFakeApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -90,7 +101,19 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public Client call123testSpecialTags(@javax.annotation.Nonnull Client client) throws ApiException { - ApiResponse localVarResponse = call123testSpecialTagsWithHttpInfo(client); + return call123testSpecialTags(client, null); + } + + /** + * To test special tags + * To test special tags and operation ID starting with number + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return Client + * @throws ApiException if fails to make API call + */ + public Client call123testSpecialTags(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { + ApiResponse localVarResponse = call123testSpecialTagsWithHttpInfo(client, headers); return localVarResponse.getData(); } @@ -102,7 +125,19 @@ public Client call123testSpecialTags(@javax.annotation.Nonnull Client client) th * @throws ApiException if fails to make API call */ public ApiResponse call123testSpecialTagsWithHttpInfo(@javax.annotation.Nonnull Client client) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = call123testSpecialTagsRequestBuilder(client); + return call123testSpecialTagsWithHttpInfo(client, null); + } + + /** + * To test special tags + * To test special tags and operation ID starting with number + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Client> + * @throws ApiException if fails to make API call + */ + public ApiResponse call123testSpecialTagsWithHttpInfo(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = call123testSpecialTagsRequestBuilder(client, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -141,7 +176,7 @@ public ApiResponse call123testSpecialTagsWithHttpInfo(@javax.annotation. } } - private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotation.Nonnull Client client) throws ApiException { + private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { // verify the required parameter 'client' is set if (client == null) { throw new ApiException(400, "Missing the required parameter 'client' when calling call123testSpecialTags"); @@ -165,6 +200,8 @@ private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java index 37eb48690777..00ef1d05bd21 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -47,6 +47,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class DefaultApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -69,6 +79,7 @@ public DefaultApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -89,7 +100,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public FooGetDefaultResponse fooGet() throws ApiException { - ApiResponse localVarResponse = fooGetWithHttpInfo(); + return fooGet(null); + } + + /** + * + * + * @param headers Optional headers to include in the request + * @return FooGetDefaultResponse + * @throws ApiException if fails to make API call + */ + public FooGetDefaultResponse fooGet(Map headers) throws ApiException { + ApiResponse localVarResponse = fooGetWithHttpInfo(headers); return localVarResponse.getData(); } @@ -100,7 +122,18 @@ public FooGetDefaultResponse fooGet() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse fooGetWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = fooGetRequestBuilder(); + return fooGetWithHttpInfo(null); + } + + /** + * + * + * @param headers Optional headers to include in the request + * @return ApiResponse<FooGetDefaultResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse fooGetWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = fooGetRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -139,7 +172,7 @@ public ApiResponse fooGetWithHttpInfo() throws ApiExcepti } } - private HttpRequest.Builder fooGetRequestBuilder() throws ApiException { + private HttpRequest.Builder fooGetRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -153,6 +186,8 @@ private HttpRequest.Builder fooGetRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java index b5361e2fbd2d..b3b2b4dc278a 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java @@ -64,6 +64,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class FakeApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -86,6 +96,7 @@ public FakeApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -106,7 +117,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public FakeBigDecimalMap200Response fakeBigDecimalMap() throws ApiException { - ApiResponse localVarResponse = fakeBigDecimalMapWithHttpInfo(); + return fakeBigDecimalMap(null); + } + + /** + * + * for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys + * @param headers Optional headers to include in the request + * @return FakeBigDecimalMap200Response + * @throws ApiException if fails to make API call + */ + public FakeBigDecimalMap200Response fakeBigDecimalMap(Map headers) throws ApiException { + ApiResponse localVarResponse = fakeBigDecimalMapWithHttpInfo(headers); return localVarResponse.getData(); } @@ -117,7 +139,18 @@ public FakeBigDecimalMap200Response fakeBigDecimalMap() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse fakeBigDecimalMapWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder(); + return fakeBigDecimalMapWithHttpInfo(null); + } + + /** + * + * for Java apache and Java native, test toUrlQueryString for maps with BegDecimal keys + * @param headers Optional headers to include in the request + * @return ApiResponse<FakeBigDecimalMap200Response> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeBigDecimalMapWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = fakeBigDecimalMapRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -156,7 +189,7 @@ public ApiResponse fakeBigDecimalMapWithHttpInfo() } } - private HttpRequest.Builder fakeBigDecimalMapRequestBuilder() throws ApiException { + private HttpRequest.Builder fakeBigDecimalMapRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -170,6 +203,8 @@ private HttpRequest.Builder fakeBigDecimalMapRequestBuilder() throws ApiExceptio if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -183,7 +218,18 @@ private HttpRequest.Builder fakeBigDecimalMapRequestBuilder() throws ApiExceptio * @throws ApiException if fails to make API call */ public HealthCheckResult fakeHealthGet() throws ApiException { - ApiResponse localVarResponse = fakeHealthGetWithHttpInfo(); + return fakeHealthGet(null); + } + + /** + * Health check endpoint + * + * @param headers Optional headers to include in the request + * @return HealthCheckResult + * @throws ApiException if fails to make API call + */ + public HealthCheckResult fakeHealthGet(Map headers) throws ApiException { + ApiResponse localVarResponse = fakeHealthGetWithHttpInfo(headers); return localVarResponse.getData(); } @@ -194,7 +240,18 @@ public HealthCheckResult fakeHealthGet() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse fakeHealthGetWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = fakeHealthGetRequestBuilder(); + return fakeHealthGetWithHttpInfo(null); + } + + /** + * Health check endpoint + * + * @param headers Optional headers to include in the request + * @return ApiResponse<HealthCheckResult> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeHealthGetWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = fakeHealthGetRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -233,7 +290,7 @@ public ApiResponse fakeHealthGetWithHttpInfo() throws ApiExce } } - private HttpRequest.Builder fakeHealthGetRequestBuilder() throws ApiException { + private HttpRequest.Builder fakeHealthGetRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -247,6 +304,8 @@ private HttpRequest.Builder fakeHealthGetRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -261,7 +320,19 @@ private HttpRequest.Builder fakeHealthGetRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public Boolean fakeOuterBooleanSerialize(@javax.annotation.Nullable Boolean body) throws ApiException { - ApiResponse localVarResponse = fakeOuterBooleanSerializeWithHttpInfo(body); + return fakeOuterBooleanSerialize(body, null); + } + + /** + * + * Test serialization of outer boolean types + * @param body Input boolean as post body (optional) + * @param headers Optional headers to include in the request + * @return Boolean + * @throws ApiException if fails to make API call + */ + public Boolean fakeOuterBooleanSerialize(@javax.annotation.Nullable Boolean body, Map headers) throws ApiException { + ApiResponse localVarResponse = fakeOuterBooleanSerializeWithHttpInfo(body, headers); return localVarResponse.getData(); } @@ -273,7 +344,19 @@ public Boolean fakeOuterBooleanSerialize(@javax.annotation.Nullable Boolean body * @throws ApiException if fails to make API call */ public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(@javax.annotation.Nullable Boolean body) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = fakeOuterBooleanSerializeRequestBuilder(body); + return fakeOuterBooleanSerializeWithHttpInfo(body, null); + } + + /** + * + * Test serialization of outer boolean types + * @param body Input boolean as post body (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Boolean> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(@javax.annotation.Nullable Boolean body, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = fakeOuterBooleanSerializeRequestBuilder(body, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -312,7 +395,7 @@ public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(@javax.annotat } } - private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annotation.Nullable Boolean body) throws ApiException { + private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annotation.Nullable Boolean body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -332,6 +415,8 @@ private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annot if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -346,7 +431,19 @@ private HttpRequest.Builder fakeOuterBooleanSerializeRequestBuilder(@javax.annot * @throws ApiException if fails to make API call */ public OuterComposite fakeOuterCompositeSerialize(@javax.annotation.Nullable OuterComposite outerComposite) throws ApiException { - ApiResponse localVarResponse = fakeOuterCompositeSerializeWithHttpInfo(outerComposite); + return fakeOuterCompositeSerialize(outerComposite, null); + } + + /** + * + * Test serialization of object with outer number type + * @param outerComposite Input composite as post body (optional) + * @param headers Optional headers to include in the request + * @return OuterComposite + * @throws ApiException if fails to make API call + */ + public OuterComposite fakeOuterCompositeSerialize(@javax.annotation.Nullable OuterComposite outerComposite, Map headers) throws ApiException { + ApiResponse localVarResponse = fakeOuterCompositeSerializeWithHttpInfo(outerComposite, headers); return localVarResponse.getData(); } @@ -358,7 +455,19 @@ public OuterComposite fakeOuterCompositeSerialize(@javax.annotation.Nullable Out * @throws ApiException if fails to make API call */ public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(@javax.annotation.Nullable OuterComposite outerComposite) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = fakeOuterCompositeSerializeRequestBuilder(outerComposite); + return fakeOuterCompositeSerializeWithHttpInfo(outerComposite, null); + } + + /** + * + * Test serialization of object with outer number type + * @param outerComposite Input composite as post body (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<OuterComposite> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(@javax.annotation.Nullable OuterComposite outerComposite, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = fakeOuterCompositeSerializeRequestBuilder(outerComposite, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -397,7 +506,7 @@ public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(@java } } - private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.annotation.Nullable OuterComposite outerComposite) throws ApiException { + private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.annotation.Nullable OuterComposite outerComposite, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -417,6 +526,8 @@ private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.ann if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -431,7 +542,19 @@ private HttpRequest.Builder fakeOuterCompositeSerializeRequestBuilder(@javax.ann * @throws ApiException if fails to make API call */ public BigDecimal fakeOuterNumberSerialize(@javax.annotation.Nullable BigDecimal body) throws ApiException { - ApiResponse localVarResponse = fakeOuterNumberSerializeWithHttpInfo(body); + return fakeOuterNumberSerialize(body, null); + } + + /** + * + * Test serialization of outer number types + * @param body Input number as post body (optional) + * @param headers Optional headers to include in the request + * @return BigDecimal + * @throws ApiException if fails to make API call + */ + public BigDecimal fakeOuterNumberSerialize(@javax.annotation.Nullable BigDecimal body, Map headers) throws ApiException { + ApiResponse localVarResponse = fakeOuterNumberSerializeWithHttpInfo(body, headers); return localVarResponse.getData(); } @@ -443,7 +566,19 @@ public BigDecimal fakeOuterNumberSerialize(@javax.annotation.Nullable BigDecimal * @throws ApiException if fails to make API call */ public ApiResponse fakeOuterNumberSerializeWithHttpInfo(@javax.annotation.Nullable BigDecimal body) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = fakeOuterNumberSerializeRequestBuilder(body); + return fakeOuterNumberSerializeWithHttpInfo(body, null); + } + + /** + * + * Test serialization of outer number types + * @param body Input number as post body (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<BigDecimal> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterNumberSerializeWithHttpInfo(@javax.annotation.Nullable BigDecimal body, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = fakeOuterNumberSerializeRequestBuilder(body, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -482,7 +617,7 @@ public ApiResponse fakeOuterNumberSerializeWithHttpInfo(@javax.annot } } - private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annotation.Nullable BigDecimal body) throws ApiException { + private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annotation.Nullable BigDecimal body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -502,6 +637,8 @@ private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annota if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -516,7 +653,19 @@ private HttpRequest.Builder fakeOuterNumberSerializeRequestBuilder(@javax.annota * @throws ApiException if fails to make API call */ public String fakeOuterStringSerialize(@javax.annotation.Nullable String body) throws ApiException { - ApiResponse localVarResponse = fakeOuterStringSerializeWithHttpInfo(body); + return fakeOuterStringSerialize(body, null); + } + + /** + * + * Test serialization of outer string types + * @param body Input string as post body (optional) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String fakeOuterStringSerialize(@javax.annotation.Nullable String body, Map headers) throws ApiException { + ApiResponse localVarResponse = fakeOuterStringSerializeWithHttpInfo(body, headers); return localVarResponse.getData(); } @@ -528,7 +677,19 @@ public String fakeOuterStringSerialize(@javax.annotation.Nullable String body) t * @throws ApiException if fails to make API call */ public ApiResponse fakeOuterStringSerializeWithHttpInfo(@javax.annotation.Nullable String body) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = fakeOuterStringSerializeRequestBuilder(body); + return fakeOuterStringSerializeWithHttpInfo(body, null); + } + + /** + * + * Test serialization of outer string types + * @param body Input string as post body (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterStringSerializeWithHttpInfo(@javax.annotation.Nullable String body, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = fakeOuterStringSerializeRequestBuilder(body, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -567,7 +728,7 @@ public ApiResponse fakeOuterStringSerializeWithHttpInfo(@javax.annotatio } } - private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annotation.Nullable String body) throws ApiException { + private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annotation.Nullable String body, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -582,6 +743,8 @@ private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annota if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -595,7 +758,18 @@ private HttpRequest.Builder fakeOuterStringSerializeRequestBuilder(@javax.annota * @throws ApiException if fails to make API call */ public List getApplicationJsonUtf8() throws ApiException { - ApiResponse> localVarResponse = getApplicationJsonUtf8WithHttpInfo(); + return getApplicationJsonUtf8(null); + } + + /** + * application/json UTF8 + * + * @param headers Optional headers to include in the request + * @return List<OuterEnum> + * @throws ApiException if fails to make API call + */ + public List getApplicationJsonUtf8(Map headers) throws ApiException { + ApiResponse> localVarResponse = getApplicationJsonUtf8WithHttpInfo(headers); return localVarResponse.getData(); } @@ -606,7 +780,18 @@ public List getApplicationJsonUtf8() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse> getApplicationJsonUtf8WithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getApplicationJsonUtf8RequestBuilder(); + return getApplicationJsonUtf8WithHttpInfo(null); + } + + /** + * application/json UTF8 + * + * @param headers Optional headers to include in the request + * @return ApiResponse<List<OuterEnum>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getApplicationJsonUtf8WithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getApplicationJsonUtf8RequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -645,7 +830,7 @@ public ApiResponse> getApplicationJsonUtf8WithHttpInfo() throws } } - private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder() throws ApiException { + private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -659,6 +844,8 @@ private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder() throws ApiExc if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -672,7 +859,18 @@ private HttpRequest.Builder getApplicationJsonUtf8RequestBuilder() throws ApiExc * @throws ApiException if fails to make API call */ public List getArrayOfEnums() throws ApiException { - ApiResponse> localVarResponse = getArrayOfEnumsWithHttpInfo(); + return getArrayOfEnums(null); + } + + /** + * Array of Enums + * + * @param headers Optional headers to include in the request + * @return List<OuterEnum> + * @throws ApiException if fails to make API call + */ + public List getArrayOfEnums(Map headers) throws ApiException { + ApiResponse> localVarResponse = getArrayOfEnumsWithHttpInfo(headers); return localVarResponse.getData(); } @@ -683,7 +881,18 @@ public List getArrayOfEnums() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse> getArrayOfEnumsWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getArrayOfEnumsRequestBuilder(); + return getArrayOfEnumsWithHttpInfo(null); + } + + /** + * Array of Enums + * + * @param headers Optional headers to include in the request + * @return ApiResponse<List<OuterEnum>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getArrayOfEnumsWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getArrayOfEnumsRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -722,7 +931,7 @@ public ApiResponse> getArrayOfEnumsWithHttpInfo() throws ApiExce } } - private HttpRequest.Builder getArrayOfEnumsRequestBuilder() throws ApiException { + private HttpRequest.Builder getArrayOfEnumsRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -736,6 +945,8 @@ private HttpRequest.Builder getArrayOfEnumsRequestBuilder() throws ApiException if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -749,7 +960,18 @@ private HttpRequest.Builder getArrayOfEnumsRequestBuilder() throws ApiException * @throws ApiException if fails to make API call */ public void testAdditionalPropertiesReference(@javax.annotation.Nonnull Map requestBody) throws ApiException { - testAdditionalPropertiesReferenceWithHttpInfo(requestBody); + testAdditionalPropertiesReference(requestBody, null); + } + + /** + * test referenced additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testAdditionalPropertiesReference(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { + testAdditionalPropertiesReferenceWithHttpInfo(requestBody, headers); } /** @@ -760,7 +982,19 @@ public void testAdditionalPropertiesReference(@javax.annotation.Nonnull Map testAdditionalPropertiesReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testAdditionalPropertiesReferenceRequestBuilder(requestBody); + return testAdditionalPropertiesReferenceWithHttpInfo(requestBody, null); + } + + /** + * test referenced additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testAdditionalPropertiesReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testAdditionalPropertiesReferenceRequestBuilder(requestBody, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -793,7 +1027,7 @@ public ApiResponse testAdditionalPropertiesReferenceWithHttpInfo(@javax.an } } - private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody) throws ApiException { + private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { // verify the required parameter 'requestBody' is set if (requestBody == null) { throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testAdditionalPropertiesReference"); @@ -817,6 +1051,8 @@ private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@jav if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -830,7 +1066,18 @@ private HttpRequest.Builder testAdditionalPropertiesReferenceRequestBuilder(@jav * @throws ApiException if fails to make API call */ public void testBodyWithFileSchema(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass) throws ApiException { - testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); + testBodyWithFileSchema(fileSchemaTestClass, null); + } + + /** + * + * For this test, the body for this request much reference a schema named `File`. + * @param fileSchemaTestClass (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testBodyWithFileSchema(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass, Map headers) throws ApiException { + testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass, headers); } /** @@ -841,7 +1088,19 @@ public void testBodyWithFileSchema(@javax.annotation.Nonnull FileSchemaTestClass * @throws ApiException if fails to make API call */ public ApiResponse testBodyWithFileSchemaWithHttpInfo(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testBodyWithFileSchemaRequestBuilder(fileSchemaTestClass); + return testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass, null); + } + + /** + * + * For this test, the body for this request much reference a schema named `File`. + * @param fileSchemaTestClass (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testBodyWithFileSchemaWithHttpInfo(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testBodyWithFileSchemaRequestBuilder(fileSchemaTestClass, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -874,7 +1133,7 @@ public ApiResponse testBodyWithFileSchemaWithHttpInfo(@javax.annotation.No } } - private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass) throws ApiException { + private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotation.Nonnull FileSchemaTestClass fileSchemaTestClass, Map headers) throws ApiException { // verify the required parameter 'fileSchemaTestClass' is set if (fileSchemaTestClass == null) { throw new ApiException(400, "Missing the required parameter 'fileSchemaTestClass' when calling testBodyWithFileSchema"); @@ -898,6 +1157,8 @@ private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -912,7 +1173,19 @@ private HttpRequest.Builder testBodyWithFileSchemaRequestBuilder(@javax.annotati * @throws ApiException if fails to make API call */ public void testBodyWithQueryParams(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user) throws ApiException { - testBodyWithQueryParamsWithHttpInfo(query, user); + testBodyWithQueryParams(query, user, null); + } + + /** + * + * + * @param query (required) + * @param user (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testBodyWithQueryParams(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + testBodyWithQueryParamsWithHttpInfo(query, user, headers); } /** @@ -924,7 +1197,20 @@ public void testBodyWithQueryParams(@javax.annotation.Nonnull String query, @jav * @throws ApiException if fails to make API call */ public ApiResponse testBodyWithQueryParamsWithHttpInfo(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testBodyWithQueryParamsRequestBuilder(query, user); + return testBodyWithQueryParamsWithHttpInfo(query, user, null); + } + + /** + * + * + * @param query (required) + * @param user (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testBodyWithQueryParamsWithHttpInfo(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testBodyWithQueryParamsRequestBuilder(query, user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -957,7 +1243,7 @@ public ApiResponse testBodyWithQueryParamsWithHttpInfo(@javax.annotation.N } } - private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'query' is set if (query == null) { throw new ApiException(400, "Missing the required parameter 'query' when calling testBodyWithQueryParams"); @@ -1000,6 +1286,8 @@ private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotat if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1014,7 +1302,19 @@ private HttpRequest.Builder testBodyWithQueryParamsRequestBuilder(@javax.annotat * @throws ApiException if fails to make API call */ public Client testClientModel(@javax.annotation.Nonnull Client client) throws ApiException { - ApiResponse localVarResponse = testClientModelWithHttpInfo(client); + return testClientModel(client, null); + } + + /** + * To test \"client\" model + * To test \"client\" model + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return Client + * @throws ApiException if fails to make API call + */ + public Client testClientModel(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { + ApiResponse localVarResponse = testClientModelWithHttpInfo(client, headers); return localVarResponse.getData(); } @@ -1026,7 +1326,19 @@ public Client testClientModel(@javax.annotation.Nonnull Client client) throws Ap * @throws ApiException if fails to make API call */ public ApiResponse testClientModelWithHttpInfo(@javax.annotation.Nonnull Client client) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testClientModelRequestBuilder(client); + return testClientModelWithHttpInfo(client, null); + } + + /** + * To test \"client\" model + * To test \"client\" model + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Client> + * @throws ApiException if fails to make API call + */ + public ApiResponse testClientModelWithHttpInfo(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testClientModelRequestBuilder(client, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1065,7 +1377,7 @@ public ApiResponse testClientModelWithHttpInfo(@javax.annotation.Nonnull } } - private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonnull Client client) throws ApiException { + private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { // verify the required parameter 'client' is set if (client == null) { throw new ApiException(400, "Missing the required parameter 'client' when calling testClientModel"); @@ -1089,6 +1401,8 @@ private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonn if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1115,7 +1429,31 @@ private HttpRequest.Builder testClientModelRequestBuilder(@javax.annotation.Nonn * @throws ApiException if fails to make API call */ public void testEndpointParameters(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) throws ApiException { - testEndpointParametersWithHttpInfo(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null); + } + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional, default to 2010-02-01T10:20:10.111110+01:00) + * @param password None (optional) + * @param paramCallback None (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testEndpointParameters(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback, Map headers) throws ApiException { + testEndpointParametersWithHttpInfo(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, headers); } /** @@ -1139,7 +1477,32 @@ public void testEndpointParameters(@javax.annotation.Nonnull BigDecimal number, * @throws ApiException if fails to make API call */ public ApiResponse testEndpointParametersWithHttpInfo(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEndpointParametersRequestBuilder(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + return testEndpointParametersWithHttpInfo(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, null); + } + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional, default to 2010-02-01T10:20:10.111110+01:00) + * @param password None (optional) + * @param paramCallback None (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEndpointParametersWithHttpInfo(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEndpointParametersRequestBuilder(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1172,7 +1535,7 @@ public ApiResponse testEndpointParametersWithHttpInfo(@javax.annotation.No } } - private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback) throws ApiException { + private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, @javax.annotation.Nullable Integer integer, @javax.annotation.Nullable Integer int32, @javax.annotation.Nullable Long int64, @javax.annotation.Nullable Float _float, @javax.annotation.Nullable String string, @javax.annotation.Nullable File binary, @javax.annotation.Nullable LocalDate date, @javax.annotation.Nullable OffsetDateTime dateTime, @javax.annotation.Nullable String password, @javax.annotation.Nullable String paramCallback, Map headers) throws ApiException { // verify the required parameter 'number' is set if (number == null) { throw new ApiException(400, "Missing the required parameter 'number' when calling testEndpointParameters"); @@ -1255,6 +1618,8 @@ private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1275,7 +1640,25 @@ private HttpRequest.Builder testEndpointParametersRequestBuilder(@javax.annotati * @throws ApiException if fails to make API call */ public void testEnumParameters(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString) throws ApiException { - testEnumParametersWithHttpInfo(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null); + } + + /** + * To test enum parameters + * To test enum parameters + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testEnumParameters(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString, Map headers) throws ApiException { + testEnumParametersWithHttpInfo(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, headers); } /** @@ -1293,7 +1676,26 @@ public void testEnumParameters(@javax.annotation.Nullable List enumHeade * @throws ApiException if fails to make API call */ public ApiResponse testEnumParametersWithHttpInfo(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testEnumParametersRequestBuilder(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + return testEnumParametersWithHttpInfo(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null); + } + + /** + * To test enum parameters + * To test enum parameters + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testEnumParametersWithHttpInfo(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testEnumParametersRequestBuilder(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1326,7 +1728,7 @@ public ApiResponse testEnumParametersWithHttpInfo(@javax.annotation.Nullab } } - private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString) throws ApiException { + private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.Nullable List enumHeaderStringArray, @javax.annotation.Nullable String enumHeaderString, @javax.annotation.Nullable List enumQueryStringArray, @javax.annotation.Nullable String enumQueryString, @javax.annotation.Nullable Integer enumQueryInteger, @javax.annotation.Nullable Double enumQueryDouble, @javax.annotation.Nullable List enumFormStringArray, @javax.annotation.Nullable String enumFormString, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1386,6 +1788,8 @@ private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.N if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1399,6 +1803,17 @@ private HttpRequest.Builder testEnumParametersRequestBuilder(@javax.annotation.N * @throws ApiException if fails to make API call */ public void testGroupParameters(APITestGroupParametersRequest apiRequest) throws ApiException { + testGroupParameters(apiRequest, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param apiRequest {@link APITestGroupParametersRequest} + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testGroupParameters(APITestGroupParametersRequest apiRequest, Map headers) throws ApiException { @javax.annotation.Nonnull Integer requiredStringGroup = apiRequest.requiredStringGroup(); @javax.annotation.Nonnull @@ -1411,7 +1826,7 @@ public void testGroupParameters(APITestGroupParametersRequest apiRequest) throws Boolean booleanGroup = apiRequest.booleanGroup(); @javax.annotation.Nullable Long int64Group = apiRequest.int64Group(); - testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); } /** @@ -1422,13 +1837,25 @@ public void testGroupParameters(APITestGroupParametersRequest apiRequest) throws * @throws ApiException if fails to make API call */ public ApiResponse testGroupParametersWithHttpInfo(APITestGroupParametersRequest apiRequest) throws ApiException { + return testGroupParametersWithHttpInfo(apiRequest, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param apiRequest {@link APITestGroupParametersRequest} + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testGroupParametersWithHttpInfo(APITestGroupParametersRequest apiRequest, Map headers) throws ApiException { Integer requiredStringGroup = apiRequest.requiredStringGroup(); Boolean requiredBooleanGroup = apiRequest.requiredBooleanGroup(); Long requiredInt64Group = apiRequest.requiredInt64Group(); Integer stringGroup = apiRequest.stringGroup(); Boolean booleanGroup = apiRequest.booleanGroup(); Long int64Group = apiRequest.int64Group(); - return testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + return testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); } /** @@ -1443,7 +1870,23 @@ public ApiResponse testGroupParametersWithHttpInfo(APITestGroupParametersR * @throws ApiException if fails to make API call */ public void testGroupParameters(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group) throws ApiException { - testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testGroupParameters(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group, Map headers) throws ApiException { + testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); } /** @@ -1459,7 +1902,24 @@ public void testGroupParameters(@javax.annotation.Nonnull Integer requiredString * @throws ApiException if fails to make API call */ public ApiResponse testGroupParametersWithHttpInfo(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testGroupParametersRequestBuilder(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + return testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, null); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param requiredStringGroup Required String in group parameters (required) + * @param requiredBooleanGroup Required Boolean in group parameters (required) + * @param requiredInt64Group Required Integer in group parameters (required) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testGroupParametersWithHttpInfo(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testGroupParametersRequestBuilder(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1492,7 +1952,7 @@ public ApiResponse testGroupParametersWithHttpInfo(@javax.annotation.Nonnu } } - private HttpRequest.Builder testGroupParametersRequestBuilder(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group) throws ApiException { + private HttpRequest.Builder testGroupParametersRequestBuilder(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, @javax.annotation.Nullable Integer stringGroup, @javax.annotation.Nullable Boolean booleanGroup, @javax.annotation.Nullable Long int64Group, Map headers) throws ApiException { // verify the required parameter 'requiredStringGroup' is set if (requiredStringGroup == null) { throw new ApiException(400, "Missing the required parameter 'requiredStringGroup' when calling testGroupParameters"); @@ -1545,6 +2005,8 @@ private HttpRequest.Builder testGroupParametersRequestBuilder(@javax.annotation. if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1647,7 +2109,18 @@ public APITestGroupParametersRequest build() { * @throws ApiException if fails to make API call */ public void testInlineAdditionalProperties(@javax.annotation.Nonnull Map requestBody) throws ApiException { - testInlineAdditionalPropertiesWithHttpInfo(requestBody); + testInlineAdditionalProperties(requestBody, null); + } + + /** + * test inline additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testInlineAdditionalProperties(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { + testInlineAdditionalPropertiesWithHttpInfo(requestBody, headers); } /** @@ -1658,7 +2131,19 @@ public void testInlineAdditionalProperties(@javax.annotation.Nonnull Map testInlineAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull Map requestBody) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testInlineAdditionalPropertiesRequestBuilder(requestBody); + return testInlineAdditionalPropertiesWithHttpInfo(requestBody, null); + } + + /** + * test inline additionalProperties + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testInlineAdditionalPropertiesRequestBuilder(requestBody, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1691,7 +2176,7 @@ public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(@javax.annot } } - private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull Map requestBody) throws ApiException { + private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { // verify the required parameter 'requestBody' is set if (requestBody == null) { throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testInlineAdditionalProperties"); @@ -1715,6 +2200,8 @@ private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax. if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1728,7 +2215,18 @@ private HttpRequest.Builder testInlineAdditionalPropertiesRequestBuilder(@javax. * @throws ApiException if fails to make API call */ public void testInlineFreeformAdditionalProperties(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) throws ApiException { - testInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest); + testInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest, null); + } + + /** + * test inline free-form additionalProperties + * + * @param testInlineFreeformAdditionalPropertiesRequest request body (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testInlineFreeformAdditionalProperties(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, Map headers) throws ApiException { + testInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest, headers); } /** @@ -1739,7 +2237,19 @@ public void testInlineFreeformAdditionalProperties(@javax.annotation.Nonnull Tes * @throws ApiException if fails to make API call */ public ApiResponse testInlineFreeformAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testInlineFreeformAdditionalPropertiesRequestBuilder(testInlineFreeformAdditionalPropertiesRequest); + return testInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest, null); + } + + /** + * test inline free-form additionalProperties + * + * @param testInlineFreeformAdditionalPropertiesRequest request body (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testInlineFreeformAdditionalPropertiesWithHttpInfo(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testInlineFreeformAdditionalPropertiesRequestBuilder(testInlineFreeformAdditionalPropertiesRequest, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1772,7 +2282,7 @@ public ApiResponse testInlineFreeformAdditionalPropertiesWithHttpInfo(@jav } } - private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) throws ApiException { + private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder(@javax.annotation.Nonnull TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, Map headers) throws ApiException { // verify the required parameter 'testInlineFreeformAdditionalPropertiesRequest' is set if (testInlineFreeformAdditionalPropertiesRequest == null) { throw new ApiException(400, "Missing the required parameter 'testInlineFreeformAdditionalPropertiesRequest' when calling testInlineFreeformAdditionalProperties"); @@ -1796,6 +2306,8 @@ private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1810,7 +2322,19 @@ private HttpRequest.Builder testInlineFreeformAdditionalPropertiesRequestBuilder * @throws ApiException if fails to make API call */ public void testJsonFormData(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2) throws ApiException { - testJsonFormDataWithHttpInfo(param, param2); + testJsonFormData(param, param2, null); + } + + /** + * test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testJsonFormData(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Map headers) throws ApiException { + testJsonFormDataWithHttpInfo(param, param2, headers); } /** @@ -1822,7 +2346,20 @@ public void testJsonFormData(@javax.annotation.Nonnull String param, @javax.anno * @throws ApiException if fails to make API call */ public ApiResponse testJsonFormDataWithHttpInfo(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testJsonFormDataRequestBuilder(param, param2); + return testJsonFormDataWithHttpInfo(param, param2, null); + } + + /** + * test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testJsonFormDataWithHttpInfo(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testJsonFormDataRequestBuilder(param, param2, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1855,7 +2392,7 @@ public ApiResponse testJsonFormDataWithHttpInfo(@javax.annotation.Nonnull } } - private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2) throws ApiException { + private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Map headers) throws ApiException { // verify the required parameter 'param' is set if (param == null) { throw new ApiException(400, "Missing the required parameter 'param' when calling testJsonFormData"); @@ -1894,6 +2431,8 @@ private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Non if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -1911,7 +2450,22 @@ private HttpRequest.Builder testJsonFormDataRequestBuilder(@javax.annotation.Non * @throws ApiException if fails to make API call */ public void testQueryParameterCollectionFormat(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context) throws ApiException { - testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context); + testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, null); + } + + /** + * + * To test the collection format in query parameters + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testQueryParameterCollectionFormat(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context, Map headers) throws ApiException { + testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, headers); } /** @@ -1926,7 +2480,23 @@ public void testQueryParameterCollectionFormat(@javax.annotation.Nonnull List testQueryParameterCollectionFormatWithHttpInfo(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testQueryParameterCollectionFormatRequestBuilder(pipe, ioutil, http, url, context); + return testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, null); + } + + /** + * + * To test the collection format in query parameters + * @param pipe (required) + * @param ioutil (required) + * @param http (required) + * @param url (required) + * @param context (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryParameterCollectionFormatWithHttpInfo(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryParameterCollectionFormatRequestBuilder(pipe, ioutil, http, url, context, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -1959,7 +2529,7 @@ public ApiResponse testQueryParameterCollectionFormatWithHttpInfo(@javax.a } } - private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context) throws ApiException { + private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context, Map headers) throws ApiException { // verify the required parameter 'pipe' is set if (pipe == null) { throw new ApiException(400, "Missing the required parameter 'pipe' when calling testQueryParameterCollectionFormat"); @@ -2016,6 +2586,8 @@ private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@ja if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -2029,7 +2601,18 @@ private HttpRequest.Builder testQueryParameterCollectionFormatRequestBuilder(@ja * @throws ApiException if fails to make API call */ public void testStringMapReference(@javax.annotation.Nonnull Map requestBody) throws ApiException { - testStringMapReferenceWithHttpInfo(requestBody); + testStringMapReference(requestBody, null); + } + + /** + * test referenced string map + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void testStringMapReference(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { + testStringMapReferenceWithHttpInfo(requestBody, headers); } /** @@ -2040,7 +2623,19 @@ public void testStringMapReference(@javax.annotation.Nonnull Map * @throws ApiException if fails to make API call */ public ApiResponse testStringMapReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody); + return testStringMapReferenceWithHttpInfo(requestBody, null); + } + + /** + * test referenced string map + * + * @param requestBody request body (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse testStringMapReferenceWithHttpInfo(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testStringMapReferenceRequestBuilder(requestBody, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -2073,7 +2668,7 @@ public ApiResponse testStringMapReferenceWithHttpInfo(@javax.annotation.No } } - private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody) throws ApiException { + private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotation.Nonnull Map requestBody, Map headers) throws ApiException { // verify the required parameter 'requestBody' is set if (requestBody == null) { throw new ApiException(400, "Missing the required parameter 'requestBody' when calling testStringMapReference"); @@ -2097,6 +2692,8 @@ private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotati if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 4f1e2d966f2f..702a7a3a7bb0 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -53,6 +53,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class FakeClassnameTags123Api { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -75,6 +85,7 @@ public FakeClassnameTags123Api(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -96,7 +107,19 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public Client testClassname(@javax.annotation.Nonnull Client client) throws ApiException { - ApiResponse localVarResponse = testClassnameWithHttpInfo(client); + return testClassname(client, null); + } + + /** + * To test class name in snake case + * To test class name in snake case + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return Client + * @throws ApiException if fails to make API call + */ + public Client testClassname(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { + ApiResponse localVarResponse = testClassnameWithHttpInfo(client, headers); return localVarResponse.getData(); } @@ -108,7 +131,19 @@ public Client testClassname(@javax.annotation.Nonnull Client client) throws ApiE * @throws ApiException if fails to make API call */ public ApiResponse testClassnameWithHttpInfo(@javax.annotation.Nonnull Client client) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = testClassnameRequestBuilder(client); + return testClassnameWithHttpInfo(client, null); + } + + /** + * To test class name in snake case + * To test class name in snake case + * @param client client model (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Client> + * @throws ApiException if fails to make API call + */ + public ApiResponse testClassnameWithHttpInfo(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testClassnameRequestBuilder(client, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -147,7 +182,7 @@ public ApiResponse testClassnameWithHttpInfo(@javax.annotation.Nonnull C } } - private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnull Client client) throws ApiException { + private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnull Client client, Map headers) throws ApiException { // verify the required parameter 'client' is set if (client == null) { throw new ApiException(400, "Missing the required parameter 'client' when calling testClassname"); @@ -171,6 +206,8 @@ private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnul if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java index e621ee755339..48c3f9ea413d 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java @@ -55,6 +55,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class PetApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -77,6 +87,7 @@ public PetApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -97,7 +108,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public void addPet(@javax.annotation.Nonnull Pet pet) throws ApiException { - addPetWithHttpInfo(pet); + addPet(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void addPet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + addPetWithHttpInfo(pet, headers); } /** @@ -108,7 +130,19 @@ public void addPet(@javax.annotation.Nonnull Pet pet) throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet); + return addPetWithHttpInfo(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -141,7 +175,7 @@ public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet) t } } - private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet) throws ApiException { + private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { // verify the required parameter 'pet' is set if (pet == null) { throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet"); @@ -165,6 +199,8 @@ private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet p if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -179,7 +215,19 @@ private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet p * @throws ApiException if fails to make API call */ public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { - deletePetWithHttpInfo(petId, apiKey); + deletePet(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + deletePetWithHttpInfo(petId, apiKey, headers); } /** @@ -191,7 +239,20 @@ public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nu * @throws ApiException if fails to make API call */ public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey); + return deletePetWithHttpInfo(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -224,7 +285,7 @@ public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long pe } } - private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); @@ -246,6 +307,8 @@ private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Lo if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -260,7 +323,19 @@ private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Lo * @throws ApiException if fails to make API call */ public List findPetsByStatus(@javax.annotation.Nonnull List status) throws ApiException { - ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status); + return findPetsByStatus(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status, headers); return localVarResponse.getData(); } @@ -272,7 +347,19 @@ public List findPetsByStatus(@javax.annotation.Nonnull List status) * @throws ApiException if fails to make API call */ public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status); + return findPetsByStatusWithHttpInfo(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -311,7 +398,7 @@ public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Non } } - private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status) throws ApiException { + private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status, Map headers) throws ApiException { // verify the required parameter 'status' is set if (status == null) { throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); @@ -344,6 +431,8 @@ private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Non if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -360,7 +449,21 @@ private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Non */ @Deprecated public List findPetsByTags(@javax.annotation.Nonnull List tags) throws ApiException { - ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags); + return findPetsByTags(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags, headers); return localVarResponse.getData(); } @@ -374,7 +477,21 @@ public List findPetsByTags(@javax.annotation.Nonnull List tags) thr */ @Deprecated public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags); + return findPetsByTagsWithHttpInfo(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -413,7 +530,7 @@ public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnu } } - private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags) throws ApiException { + private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { // verify the required parameter 'tags' is set if (tags == null) { throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); @@ -446,6 +563,8 @@ private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnu if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -460,7 +579,19 @@ private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnu * @throws ApiException if fails to make API call */ public Pet getPetById(@javax.annotation.Nonnull Long petId) throws ApiException { - ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId); + return getPetById(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId, headers); return localVarResponse.getData(); } @@ -472,7 +603,19 @@ public Pet getPetById(@javax.annotation.Nonnull Long petId) throws ApiException * @throws ApiException if fails to make API call */ public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId); + return getPetByIdWithHttpInfo(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -511,7 +654,7 @@ public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long pe } } - private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId) throws ApiException { + private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); @@ -530,6 +673,8 @@ private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull L if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -543,7 +688,18 @@ private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull L * @throws ApiException if fails to make API call */ public void updatePet(@javax.annotation.Nonnull Pet pet) throws ApiException { - updatePetWithHttpInfo(pet); + updatePet(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updatePet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + updatePetWithHttpInfo(pet, headers); } /** @@ -554,7 +710,19 @@ public void updatePet(@javax.annotation.Nonnull Pet pet) throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet); + return updatePetWithHttpInfo(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -587,7 +755,7 @@ public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet } } - private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet) throws ApiException { + private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { // verify the required parameter 'pet' is set if (pet == null) { throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"); @@ -611,6 +779,8 @@ private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pe if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -626,7 +796,20 @@ private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pe * @throws ApiException if fails to make API call */ public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { - updatePetWithFormWithHttpInfo(petId, name, status); + updatePetWithForm(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + updatePetWithFormWithHttpInfo(petId, name, status, headers); } /** @@ -639,7 +822,21 @@ public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annot * @throws ApiException if fails to make API call */ public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status); + return updatePetWithFormWithHttpInfo(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -672,7 +869,7 @@ public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull } } - private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); @@ -708,6 +905,8 @@ private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.No if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -724,7 +923,21 @@ private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.No * @throws ApiException if fails to make API call */ public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { - ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file); + return uploadFile(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file, headers); return localVarResponse.getData(); } @@ -738,7 +951,21 @@ public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax. * @throws ApiException if fails to make API call */ public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file); + return uploadFileWithHttpInfo(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -777,7 +1004,7 @@ public ApiResponse uploadFileWithHttpInfo(@javax.annotation.No } } - private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); @@ -832,6 +1059,8 @@ private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull L if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -848,7 +1077,21 @@ private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull L * @throws ApiException if fails to make API call */ public ModelApiResponse uploadFileWithRequiredFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata) throws ApiException { - ApiResponse localVarResponse = uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata); + return uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, null); + } + + /** + * uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param headers Optional headers to include in the request + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFileWithRequiredFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata, Map headers) throws ApiException { + ApiResponse localVarResponse = uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata, headers); return localVarResponse.getData(); } @@ -862,7 +1105,21 @@ public ModelApiResponse uploadFileWithRequiredFile(@javax.annotation.Nonnull Lon * @throws ApiException if fails to make API call */ public ApiResponse uploadFileWithRequiredFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = uploadFileWithRequiredFileRequestBuilder(petId, requiredFile, additionalMetadata); + return uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata, null); + } + + /** + * uploads an image (required) + * + * @param petId ID of pet to update (required) + * @param requiredFile file to upload (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithRequiredFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = uploadFileWithRequiredFileRequestBuilder(petId, requiredFile, additionalMetadata, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -901,7 +1158,7 @@ public ApiResponse uploadFileWithRequiredFileWithHttpInfo(@jav } } - private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata) throws ApiException { + private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, @javax.annotation.Nullable String additionalMetadata, Map headers) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); @@ -960,6 +1217,8 @@ private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.anno if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java index 278213ecb8ed..0c0c6f44053d 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java @@ -53,6 +53,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class StoreApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -75,6 +85,7 @@ public StoreApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -95,7 +106,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public void deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiException { - deleteOrderWithHttpInfo(orderId); + deleteOrder(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + deleteOrderWithHttpInfo(orderId, headers); } /** @@ -106,7 +128,19 @@ public void deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiExce * @throws ApiException if fails to make API call */ public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId); + return deleteOrderWithHttpInfo(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -139,7 +173,7 @@ public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull Strin } } - private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId) throws ApiException { + private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); @@ -158,6 +192,8 @@ private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -171,7 +207,18 @@ private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public Map getInventory() throws ApiException { - ApiResponse> localVarResponse = getInventoryWithHttpInfo(); + return getInventory(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory(Map headers) throws ApiException { + ApiResponse> localVarResponse = getInventoryWithHttpInfo(headers); return localVarResponse.getData(); } @@ -182,7 +229,18 @@ public Map getInventory() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse> getInventoryWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(); + return getInventoryWithHttpInfo(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -221,7 +279,7 @@ public ApiResponse> getInventoryWithHttpInfo() throws ApiEx } } - private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { + private HttpRequest.Builder getInventoryRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -235,6 +293,8 @@ private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -249,7 +309,19 @@ private HttpRequest.Builder getInventoryRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public Order getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiException { - ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId); + return getOrderById(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId, headers); return localVarResponse.getData(); } @@ -261,7 +333,19 @@ public Order getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiExce * @throws ApiException if fails to make API call */ public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId); + return getOrderByIdWithHttpInfo(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -300,7 +384,7 @@ public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Lon } } - private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId) throws ApiException { + private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); @@ -319,6 +403,8 @@ private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -333,7 +419,19 @@ private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull * @throws ApiException if fails to make API call */ public Order placeOrder(@javax.annotation.Nonnull Order order) throws ApiException { - ApiResponse localVarResponse = placeOrderWithHttpInfo(order); + return placeOrder(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + ApiResponse localVarResponse = placeOrderWithHttpInfo(order, headers); return localVarResponse.getData(); } @@ -345,7 +443,19 @@ public Order placeOrder(@javax.annotation.Nonnull Order order) throws ApiExcepti * @throws ApiException if fails to make API call */ public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order); + return placeOrderWithHttpInfo(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -384,7 +494,7 @@ public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order } } - private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order) throws ApiException { + private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { // verify the required parameter 'order' is set if (order == null) { throw new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"); @@ -408,6 +518,8 @@ private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull O if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java index 589405a76a62..ad5b8382f32d 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java @@ -54,6 +54,16 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT") public class UserApi { + private static class HttpRequestBuilderExtensions { + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; private final String memberVarBaseUri; @@ -76,6 +86,7 @@ public UserApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); @@ -96,7 +107,18 @@ private String formatExceptionMessage(String operationId, int statusCode, String * @throws ApiException if fails to make API call */ public void createUser(@javax.annotation.Nonnull User user) throws ApiException { - createUserWithHttpInfo(user); + createUser(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + createUserWithHttpInfo(user, headers); } /** @@ -107,7 +129,19 @@ public void createUser(@javax.annotation.Nonnull User user) throws ApiException * @throws ApiException if fails to make API call */ public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user); + return createUserWithHttpInfo(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -140,7 +174,7 @@ public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User u } } - private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUser"); @@ -164,6 +198,8 @@ private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull U if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -177,7 +213,18 @@ private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull U * @throws ApiException if fails to make API call */ public void createUsersWithArrayInput(@javax.annotation.Nonnull List user) throws ApiException { - createUsersWithArrayInputWithHttpInfo(user); + createUsersWithArrayInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithArrayInputWithHttpInfo(user, headers); } /** @@ -188,7 +235,19 @@ public void createUsersWithArrayInput(@javax.annotation.Nonnull List user) * @throws ApiException if fails to make API call */ public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user); + return createUsersWithArrayInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -221,7 +280,7 @@ public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation } } - private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user) throws ApiException { + private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"); @@ -245,6 +304,8 @@ private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annot if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -258,7 +319,18 @@ private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annot * @throws ApiException if fails to make API call */ public void createUsersWithListInput(@javax.annotation.Nonnull List user) throws ApiException { - createUsersWithListInputWithHttpInfo(user); + createUsersWithListInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithListInputWithHttpInfo(user, headers); } /** @@ -269,7 +341,19 @@ public void createUsersWithListInput(@javax.annotation.Nonnull List user) * @throws ApiException if fails to make API call */ public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user); + return createUsersWithListInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -302,7 +386,7 @@ public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation. } } - private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user) throws ApiException { + private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { // verify the required parameter 'user' is set if (user == null) { throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"); @@ -326,6 +410,8 @@ private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annota if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -339,7 +425,18 @@ private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annota * @throws ApiException if fails to make API call */ public void deleteUser(@javax.annotation.Nonnull String username) throws ApiException { - deleteUserWithHttpInfo(username); + deleteUser(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + deleteUserWithHttpInfo(username, headers); } /** @@ -350,7 +447,19 @@ public void deleteUser(@javax.annotation.Nonnull String username) throws ApiExce * @throws ApiException if fails to make API call */ public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username); + return deleteUserWithHttpInfo(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -383,7 +492,7 @@ public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String } } - private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username) throws ApiException { + private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); @@ -402,6 +511,8 @@ private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull S if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -416,7 +527,19 @@ private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull S * @throws ApiException if fails to make API call */ public User getUserByName(@javax.annotation.Nonnull String username) throws ApiException { - ApiResponse localVarResponse = getUserByNameWithHttpInfo(username); + return getUserByName(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + ApiResponse localVarResponse = getUserByNameWithHttpInfo(username, headers); return localVarResponse.getData(); } @@ -428,7 +551,19 @@ public User getUserByName(@javax.annotation.Nonnull String username) throws ApiE * @throws ApiException if fails to make API call */ public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username); + return getUserByNameWithHttpInfo(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -467,7 +602,7 @@ public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull Str } } - private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username) throws ApiException { + private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); @@ -486,6 +621,8 @@ private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnul if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -501,7 +638,20 @@ private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnul * @throws ApiException if fails to make API call */ public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { - ApiResponse localVarResponse = loginUserWithHttpInfo(username, password); + return loginUser(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + ApiResponse localVarResponse = loginUserWithHttpInfo(username, password, headers); return localVarResponse.getData(); } @@ -514,7 +664,20 @@ public String loginUser(@javax.annotation.Nonnull String username, @javax.annota * @throws ApiException if fails to make API call */ public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password); + return loginUserWithHttpInfo(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -553,7 +716,7 @@ public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull Strin } } - private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); @@ -592,6 +755,8 @@ private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull St if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -604,7 +769,17 @@ private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull St * @throws ApiException if fails to make API call */ public void logoutUser() throws ApiException { - logoutUserWithHttpInfo(); + logoutUser(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void logoutUser(Map headers) throws ApiException { + logoutUserWithHttpInfo(headers); } /** @@ -614,7 +789,18 @@ public void logoutUser() throws ApiException { * @throws ApiException if fails to make API call */ public ApiResponse logoutUserWithHttpInfo() throws ApiException { - HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(); + return logoutUserWithHttpInfo(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -647,7 +833,7 @@ public ApiResponse logoutUserWithHttpInfo() throws ApiException { } } - private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { + private HttpRequest.Builder logoutUserRequestBuilder(Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -661,6 +847,8 @@ private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } @@ -675,7 +863,19 @@ private HttpRequest.Builder logoutUserRequestBuilder() throws ApiException { * @throws ApiException if fails to make API call */ public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { - updateUserWithHttpInfo(username, user); + updateUser(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + updateUserWithHttpInfo(username, user, headers); } /** @@ -687,7 +887,20 @@ public void updateUser(@javax.annotation.Nonnull String username, @javax.annotat * @throws ApiException if fails to make API call */ public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user); + return updateUserWithHttpInfo(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( localVarRequestBuilder.build(), @@ -720,7 +933,7 @@ public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String } } - private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); @@ -749,6 +962,8 @@ private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull S if (memberVarReadTimeout != null) { localVarRequestBuilder.timeout(memberVarReadTimeout); } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); if (memberVarInterceptor != null) { memberVarInterceptor.accept(localVarRequestBuilder); } diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/.github/workflows/maven.yml b/samples/client/petstore/java/native/test-regenerated-fixed/.github/workflows/maven.yml new file mode 100644 index 000000000000..460f78bfd1b2 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/.github/workflows/maven.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build OpenAPI Petstore + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 17, 21 ] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/.gitignore b/samples/client/petstore/java/native/test-regenerated-fixed/.gitignore new file mode 100644 index 000000000000..a530464afa1b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/.gitignore @@ -0,0 +1,21 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator-ignore b/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator/FILES b/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator/FILES new file mode 100644 index 000000000000..57d506c4c50b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator/FILES @@ -0,0 +1,56 @@ +.github/workflows/maven.yml +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +build.gradle +build.sbt +docs/Category.md +docs/ModelApiResponse.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +git_push.sh +gradle.properties +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/AndroidManifest.xml +src/main/java/org/openapitools/client/ApiClient.java +src/main/java/org/openapitools/client/ApiException.java +src/main/java/org/openapitools/client/ApiResponse.java +src/main/java/org/openapitools/client/Configuration.java +src/main/java/org/openapitools/client/JSON.java +src/main/java/org/openapitools/client/Pair.java +src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java +src/main/java/org/openapitools/client/ServerConfiguration.java +src/main/java/org/openapitools/client/ServerVariable.java +src/main/java/org/openapitools/client/api/PetApi.java +src/main/java/org/openapitools/client/api/StoreApi.java +src/main/java/org/openapitools/client/api/UserApi.java +src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java +src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ModelApiResponse.java +src/main/java/org/openapitools/client/model/Order.java +src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Tag.java +src/main/java/org/openapitools/client/model/User.java +src/test/java/org/openapitools/client/api/PetApiTest.java +src/test/java/org/openapitools/client/api/StoreApiTest.java +src/test/java/org/openapitools/client/api/UserApiTest.java +src/test/java/org/openapitools/client/model/CategoryTest.java +src/test/java/org/openapitools/client/model/ModelApiResponseTest.java +src/test/java/org/openapitools/client/model/OrderTest.java +src/test/java/org/openapitools/client/model/PetTest.java +src/test/java/org/openapitools/client/model/TagTest.java +src/test/java/org/openapitools/client/model/UserTest.java diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator/VERSION b/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator/VERSION new file mode 100644 index 000000000000..fc74d6ceba8e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.15.0-SNAPSHOT diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/.travis.yml b/samples/client/petstore/java/native/test-regenerated-fixed/.travis.yml new file mode 100644 index 000000000000..c94647479234 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/.travis.yml @@ -0,0 +1,16 @@ +# +# Generated by: https://openapi-generator.tech +# +language: java +jdk: + - oraclejdk11 +before_install: + # ensure gradlew has proper permission + - chmod a+x ./gradlew +script: + # test using maven + - mvn test + # uncomment below to test using gradle + # - gradle test + # uncomment below to test using sbt + # - sbt test diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/README.md b/samples/client/petstore/java/native/test-regenerated-fixed/README.md new file mode 100644 index 000000000000..182c442842d3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/README.md @@ -0,0 +1,197 @@ +# openapi-java-client + +OpenAPI Petstore + +- API version: 1.0.0 + +- Build date: 2025-07-08T21:07:41.448223+07:00[Asia/Bangkok] + +- Generator version: 7.15.0-SNAPSHOT + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + +## Requirements + +Building the API client library requires: + +1. Java 11+ +2. Maven/Gradle + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn clean deploy +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + org.openapitools + openapi-java-client + 1.0.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "org.openapitools:openapi-java-client:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +- `target/openapi-java-client-1.0.0.jar` +- `target/lib/*.jar` + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import org.openapitools.client.*; +import org.openapitools.client.model.*; +import org.openapitools.client.api.PetApi; + +public class PetApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + // Configure clients using the `defaultClient` object, such as + // overriding the host and port, timeout, etc. + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetWithHttpInfo**](docs/PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**deletePetWithHttpInfo**](docs/PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByStatusWithHttpInfo**](docs/PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**findPetsByTagsWithHttpInfo**](docs/PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**getPetByIdWithHttpInfo**](docs/PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithHttpInfo**](docs/PetApi.md#updatePetWithHttpInfo) | **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* | [**updatePetWithFormWithHttpInfo**](docs/PetApi.md#updatePetWithFormWithHttpInfo) | **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* | [**uploadFileWithHttpInfo**](docs/PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**deleteOrderWithHttpInfo**](docs/StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryWithHttpInfo**](docs/StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**getOrderByIdWithHttpInfo**](docs/StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*StoreApi* | [**placeOrderWithHttpInfo**](docs/StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUserWithHttpInfo**](docs/UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithArrayInputWithHttpInfo**](docs/UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**createUsersWithListInputWithHttpInfo**](docs/UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**deleteUserWithHttpInfo**](docs/UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**getUserByNameWithHttpInfo**](docs/UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**loginUserWithHttpInfo**](docs/UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**logoutUserWithHttpInfo**](docs/UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user +*UserApi* | [**updateUserWithHttpInfo**](docs/UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Category](docs/Category.md) + - [ModelApiResponse](docs/ModelApiResponse.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### petstore_auth + + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + + +### api_key + + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. +However, the instances of the api clients created from the `ApiClient` are thread-safe and can be re-used. + +## Author + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/api/openapi.yaml b/samples/client/petstore/java/native/test-regenerated-fixed/api/openapi.yaml new file mode 100644 index 000000000000..9b1b54b9454b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/api/openapi.yaml @@ -0,0 +1,865 @@ +openapi: 3.0.0 +info: + description: "This is a sample server Petstore server. For this sample, you can\ + \ use the api key `special-key` to test the authorization filters." + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://petstore.swagger.io/v2 +tags: +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user +paths: + /pet: + post: + description: "" + operationId: addPet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + put: + description: "" + operationId: updatePet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + "405": + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /pet/findByStatus: + get: + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - description: Status values that need to be considered for filter + explode: false + in: query + name: status + required: true + schema: + items: + default: available + enum: + - available + - pending + - sold + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid status value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by status + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/findByTags: + get: + deprecated: true + description: "Multiple tags can be provided with comma separated strings. Use\ + \ tag1, tag2, tag3 for testing." + operationId: findPetsByTags + parameters: + - description: Tags to filter by + explode: false + in: query + name: tags + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid tag value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/{petId}: + delete: + description: "" + operationId: deletePet + parameters: + - explode: false + in: header + name: api_key + required: false + schema: + type: string + style: simple + - description: Pet id to delete + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "400": + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet + tags: + - pet + x-accepts: + - application/json + get: + description: Returns a single pet + operationId: getPetById + parameters: + - description: ID of pet to return + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: + - application/json + - application/xml + post: + description: "" + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/updatePetWithForm_request" + responses: + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-content-type: application/x-www-form-urlencoded + x-accepts: + - application/json + /pet/{petId}/uploadImage: + post: + description: "" + operationId: uploadFile + 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/uploadFile_request" + 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 + x-content-type: multipart/form-data + x-accepts: + - application/json + /store/inventory: + get: + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + "200": + content: + application/json: + schema: + additionalProperties: + format: int32 + type: integer + type: object + description: successful operation + security: + - api_key: [] + summary: Returns pet inventories by status + tags: + - store + x-accepts: + - application/json + /store/order: + post: + description: "" + operationId: placeOrder + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Order" + description: order placed for purchasing the pet + required: true + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /store/order/{orderId}: + delete: + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - description: ID of the order that needs to be deleted + explode: false + in: path + name: orderId + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Delete purchase order by ID + tags: + - store + x-accepts: + - application/json + get: + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generate exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + explode: false + in: path + name: orderId + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Find purchase order by ID + tags: + - store + x-accepts: + - application/json + - application/xml + /user: + post: + description: This can only be done by the logged in user. + operationId: createUser + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Created user object + required: true + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Create user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithArray: + post: + description: "" + operationId: createUsersWithArrayInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithList: + post: + description: "" + operationId: createUsersWithListInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/login: + get: + description: "" + operationId: loginUser + parameters: + - description: The user name for login + explode: true + in: query + name: username + required: true + schema: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + style: form + - description: The password for login in clear text + explode: true + in: query + name: password + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + Set-Cookie: + description: Cookie authentication key for use with the `api_key` apiKey + authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple + X-Rate-Limit: + description: calls per hour allowed by the user + explode: false + schema: + format: int32 + type: integer + style: simple + X-Expires-After: + description: date in UTC when token expires + explode: false + schema: + format: date-time + type: string + style: simple + "400": + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: + - application/json + - application/xml + /user/logout: + get: + description: "" + operationId: logoutUser + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Logs out current logged in user session + tags: + - user + x-accepts: + - application/json + /user/{username}: + delete: + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - description: The name that needs to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid username supplied + "404": + description: User not found + security: + - api_key: [] + summary: Delete user + tags: + - user + x-accepts: + - application/json + get: + description: "" + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/User" + application/json: + schema: + $ref: "#/components/schemas/User" + description: successful operation + "400": + description: Invalid username supplied + "404": + description: User not found + summary: Get user by user name + tags: + - user + x-accepts: + - application/json + - application/xml + put: + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - description: name that need to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Updated user object + required: true + responses: + "400": + description: Invalid user supplied + "404": + description: User not found + security: + - api_key: [] + summary: Updated user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json +components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: "#/components/schemas/User" + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + application/xml: + schema: + $ref: "#/components/schemas/Pet" + description: Pet object that needs to be added to the store + required: true + schemas: + ApiResponse: + description: Describes the result of uploading an image resource + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + title: An uploaded response + type: object + Pet: + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + category: + $ref: "#/components/schemas/Category" + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: "#/components/schemas/Tag" + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + title: a Pet + type: object + xml: + name: Pet + Order: + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + title: Pet Order + type: object + xml: + name: Order + User: + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + description: User Status + format: int32 + type: integer + title: a User + type: object + xml: + name: User + Category: + description: A category for a pet + example: + name: name + id: 6 + properties: + id: + format: int64 + type: integer + name: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + title: Pet category + type: object + xml: + name: Category + Tag: + description: A tag for a pet + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + title: Pet Tag + type: object + xml: + name: Tag + updatePetWithForm_request: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + uploadFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object + securitySchemes: + petstore_auth: + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + type: oauth2 + api_key: + in: header + name: api_key + type: apiKey + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/build.gradle b/samples/client/petstore/java/native/test-regenerated-fixed/build.gradle new file mode 100644 index 000000000000..56fa470fb767 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/build.gradle @@ -0,0 +1,109 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'com.diffplug.spotless' + +group = 'org.openapitools' +version = '1.0.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} + +apply plugin: 'java' +apply plugin: 'maven-publish' + +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 + +// Some text from the schema is copy pasted into the source files as UTF-8 +// but the default still seems to be to use platform encoding +tasks.withType(JavaCompile) { + configure(options) { + options.encoding = 'UTF-8' + } +} +javadoc { + options.encoding = 'UTF-8' +} + +publishing { + publications { + maven(MavenPublication) { + artifactId = 'openapi-java-client' + from components.java + } + } +} + +task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath +} + +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + + +ext { + jackson_version = "2.17.1" + jakarta_annotation_version = "1.3.5" + beanvalidation_version = "2.0.2" + junit_version = "5.10.2" + httpmime_version = "4.5.13" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" + implementation "org.openapitools:jackson-databind-nullable:0.2.1" + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + implementation "org.apache.httpcomponents:httpmime:$httpmime_version" + testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + removeUnusedImports() + importOrder() + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/build.sbt b/samples/client/petstore/java/native/test-regenerated-fixed/build.sbt new file mode 100644 index 000000000000..464090415c47 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/build.sbt @@ -0,0 +1 @@ +# TODO diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/Category.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Category.md new file mode 100644 index 000000000000..a7fc939d252e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Category.md @@ -0,0 +1,15 @@ + + +# Category + +A category for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/ModelApiResponse.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/ModelApiResponse.md new file mode 100644 index 000000000000..cd7e3c400be6 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/ModelApiResponse.md @@ -0,0 +1,16 @@ + + +# ModelApiResponse + +Describes the result of uploading an image resource + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/Order.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Order.md new file mode 100644 index 000000000000..0c33059b8b6a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Order.md @@ -0,0 +1,29 @@ + + +# Order + +An order for a pets from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**petId** | **Long** | | [optional] | +|**quantity** | **Integer** | | [optional] | +|**shipDate** | **OffsetDateTime** | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] | +|**complete** | **Boolean** | | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| PLACED | "placed" | +| APPROVED | "approved" | +| DELIVERED | "delivered" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/Pet.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Pet.md new file mode 100644 index 000000000000..8bb363301232 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Pet.md @@ -0,0 +1,29 @@ + + +# Pet + +A pet for sale in the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**category** | [**Category**](Category.md) | | [optional] | +|**name** | **String** | | | +|**photoUrls** | **List<String>** | | | +|**tags** | [**List<Tag>**](Tag.md) | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| AVAILABLE | "available" | +| PENDING | "pending" | +| SOLD | "sold" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/PetApi.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/PetApi.md new file mode 100644 index 000000000000..51f089e85389 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/PetApi.md @@ -0,0 +1,1212 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store | +| [**addPetWithHttpInfo**](PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store | +| [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet | +| [**deletePetWithHttpInfo**](PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet | +| [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByStatusWithHttpInfo**](PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags | +| [**findPetsByTagsWithHttpInfo**](PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags | +| [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID | +| [**getPetByIdWithHttpInfo**](PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID | +| [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet | +| [**updatePetWithHttpInfo**](PetApi.md#updatePetWithHttpInfo) | **PUT** /pet | Update an existing pet | +| [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**updatePetWithFormWithHttpInfo**](PetApi.md#updatePetWithFormWithHttpInfo) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image | +| [**uploadFileWithHttpInfo**](PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image | + + + +## addPet + +> Pet addPet(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + +## addPetWithHttpInfo + +> ApiResponse addPet addPetWithHttpInfo(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.addPetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + + +## deletePet + +> void deletePet(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + apiInstance.deletePet(petId, apiKey); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + +## deletePetWithHttpInfo + +> ApiResponse deletePet deletePetWithHttpInfo(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + ApiResponse response = apiInstance.deletePetWithHttpInfo(petId, apiKey); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + + +## findPetsByStatus + +> List findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + List result = apiInstance.findPetsByStatus(status); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + +## findPetsByStatusWithHttpInfo + +> ApiResponse> findPetsByStatus findPetsByStatusWithHttpInfo(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + ApiResponse> response = apiInstance.findPetsByStatusWithHttpInfo(status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + + +## findPetsByTags + +> List findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + List result = apiInstance.findPetsByTags(tags); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + +## findPetsByTagsWithHttpInfo + +> ApiResponse> findPetsByTags findPetsByTagsWithHttpInfo(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + ApiResponse> response = apiInstance.findPetsByTagsWithHttpInfo(tags); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + + +## getPetById + +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + Pet result = apiInstance.getPetById(petId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +## getPetByIdWithHttpInfo + +> ApiResponse getPetById getPetByIdWithHttpInfo(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + ApiResponse response = apiInstance.getPetByIdWithHttpInfo(petId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + + +## updatePet + +> Pet updatePet(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.updatePet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + +## updatePetWithHttpInfo + +> ApiResponse updatePet updatePetWithHttpInfo(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.updatePetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + + +## updatePetWithForm + +> void updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + apiInstance.updatePetWithForm(petId, name, status); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +## updatePetWithFormWithHttpInfo + +> ApiResponse updatePetWithForm updatePetWithFormWithHttpInfo(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + ApiResponse response = apiInstance.updatePetWithFormWithHttpInfo(petId, name, status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + + +## uploadFile + +> ModelApiResponse uploadFile(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, _file); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +[**ModelApiResponse**](ModelApiResponse.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 | - | + +## uploadFileWithHttpInfo + +> ApiResponse uploadFile uploadFileWithHttpInfo(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ApiResponse response = apiInstance.uploadFileWithHttpInfo(petId, additionalMetadata, _file); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +ApiResponse<[**ModelApiResponse**](ModelApiResponse.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 | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/StoreApi.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/StoreApi.md new file mode 100644 index 000000000000..7dfbbe315c11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/StoreApi.md @@ -0,0 +1,564 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**deleteOrderWithHttpInfo**](StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status | +| [**getInventoryWithHttpInfo**](StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status | +| [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**getOrderByIdWithHttpInfo**](StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet | +| [**placeOrderWithHttpInfo**](StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet | + + + +## deleteOrder + +> void deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + apiInstance.deleteOrder(orderId); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## deleteOrderWithHttpInfo + +> ApiResponse deleteOrder deleteOrderWithHttpInfo(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + ApiResponse response = apiInstance.deleteOrderWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## getInventory + +> Map getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + Map result = apiInstance.getInventory(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**Map<String, Integer>** + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +## getInventoryWithHttpInfo + +> ApiResponse> getInventory getInventoryWithHttpInfo() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + ApiResponse> response = apiInstance.getInventoryWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +ApiResponse<**Map<String, Integer>**> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + +## getOrderById + +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + Order result = apiInstance.getOrderById(orderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## getOrderByIdWithHttpInfo + +> ApiResponse getOrderById getOrderByIdWithHttpInfo(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + ApiResponse response = apiInstance.getOrderByIdWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## placeOrder + +> Order placeOrder(order) + +Place an order for a pet + + + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + Order result = apiInstance.placeOrder(order); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + +## placeOrderWithHttpInfo + +> ApiResponse placeOrder placeOrderWithHttpInfo(order) + +Place an order for a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + ApiResponse response = apiInstance.placeOrderWithHttpInfo(order); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/Tag.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Tag.md new file mode 100644 index 000000000000..abfde4afb501 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/Tag.md @@ -0,0 +1,15 @@ + + +# Tag + +A tag for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/User.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/User.md new file mode 100644 index 000000000000..426845227bd3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/User.md @@ -0,0 +1,21 @@ + + +# User + +A User who is purchasing from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**username** | **String** | | [optional] | +|**firstName** | **String** | | [optional] | +|**lastName** | **String** | | [optional] | +|**email** | **String** | | [optional] | +|**password** | **String** | | [optional] | +|**phone** | **String** | | [optional] | +|**userStatus** | **Integer** | User Status | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/docs/UserApi.md b/samples/client/petstore/java/native/test-regenerated-fixed/docs/UserApi.md new file mode 100644 index 000000000000..da72405c908b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/docs/UserApi.md @@ -0,0 +1,1178 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**createUser**](UserApi.md#createUser) | **POST** /user | Create user | +| [**createUserWithHttpInfo**](UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user | +| [**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithArrayInputWithHttpInfo**](UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array | +| [**createUsersWithListInputWithHttpInfo**](UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array | +| [**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user | +| [**deleteUserWithHttpInfo**](UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user | +| [**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name | +| [**getUserByNameWithHttpInfo**](UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name | +| [**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system | +| [**loginUserWithHttpInfo**](UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system | +| [**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session | +| [**logoutUserWithHttpInfo**](UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session | +| [**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user | +| [**updateUserWithHttpInfo**](UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user | + + + +## createUser + +> void createUser(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + apiInstance.createUser(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUserWithHttpInfo + +> ApiResponse createUser createUserWithHttpInfo(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + ApiResponse response = apiInstance.createUserWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithArrayInput + +> void createUsersWithArrayInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithArrayInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithArrayInputWithHttpInfo + +> ApiResponse createUsersWithArrayInput createUsersWithArrayInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithArrayInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithListInput + +> void createUsersWithListInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithListInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithListInputWithHttpInfo + +> ApiResponse createUsersWithListInput createUsersWithListInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithListInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## deleteUser + +> void deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + apiInstance.deleteUser(username); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## deleteUserWithHttpInfo + +> ApiResponse deleteUser deleteUserWithHttpInfo(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + ApiResponse response = apiInstance.deleteUserWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## getUserByName + +> User getUserByName(username) + +Get user by user name + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + User result = apiInstance.getUserByName(username); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +[**User**](User.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## getUserByNameWithHttpInfo + +> ApiResponse getUserByName getUserByNameWithHttpInfo(username) + +Get user by user name + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + ApiResponse response = apiInstance.getUserByNameWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +ApiResponse<[**User**](User.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## loginUser + +> String loginUser(username, password) + +Logs user into the system + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + String result = apiInstance.loginUser(username, password); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +**String** + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + +## loginUserWithHttpInfo + +> ApiResponse loginUser loginUserWithHttpInfo(username, password) + +Logs user into the system + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + ApiResponse response = apiInstance.loginUserWithHttpInfo(username, password); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +ApiResponse<**String**> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + + +## logoutUser + +> void logoutUser() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + apiInstance.logoutUser(); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## logoutUserWithHttpInfo + +> ApiResponse logoutUser logoutUserWithHttpInfo() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + ApiResponse response = apiInstance.logoutUserWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## updateUser + +> void updateUser(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + apiInstance.updateUser(username, user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + +## updateUserWithHttpInfo + +> ApiResponse updateUser updateUserWithHttpInfo(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + ApiResponse response = apiInstance.updateUserWithHttpInfo(username, user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/git_push.sh b/samples/client/petstore/java/native/test-regenerated-fixed/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/gradle.properties b/samples/client/petstore/java/native/test-regenerated-fixed/gradle.properties new file mode 100644 index 000000000000..a3408578278a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/gradle.properties @@ -0,0 +1,6 @@ +# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/java/native/test-regenerated-fixed/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..e6441136f3d4 Binary files /dev/null and b/samples/client/petstore/java/native/test-regenerated-fixed/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/java/native/test-regenerated-fixed/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..b82aa23a4f05 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/gradlew b/samples/client/petstore/java/native/test-regenerated-fixed/gradlew new file mode 100644 index 000000000000..9d0ce634cb11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/gradlew.bat b/samples/client/petstore/java/native/test-regenerated-fixed/gradlew.bat new file mode 100644 index 000000000000..25da30dbdeee --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/pom.xml b/samples/client/petstore/java/native/test-regenerated-fixed/pom.xml new file mode 100644 index 000000000000..10a3beca26fb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/pom.xml @@ -0,0 +1,264 @@ + + 4.0.0 + org.openapitools + openapi-java-client + jar + openapi-java-client + 1.0.0 + https://github.com/openapitools/openapi-generator + OpenAPI Java + + scm:git:git@github.com:openapitools/openapi-generator.git + scm:git:git@github.com:openapitools/openapi-generator.git + https://github.com/openapitools/openapi-generator + + + + + Unlicense + https://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + + OpenAPI-Generator Contributors + team@openapitools.org + OpenAPITools.org + http://openapitools.org + + + + + + + maven-enforcer-plugin + 3.1.0 + + + enforce-maven + + enforce + + + + + 3 + + + 11 + + + + + + + + maven-surefire-plugin + 3.2.5 + + + conf/log4j.properties + + -Xms512m -Xmx1500m + methods + 10 + + + + maven-dependency-plugin + 3.3.0 + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + test-jar + + + + + + + + maven-compiler-plugin + 3.10.1 + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.4.1 + + + attach-javadocs + + jar + + + + + + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + + + + .gitignore + + + + + + true + 4 + + + + + + + + + + 1.8 + + true + + + + + + + + + + + + sign-artifacts + + + + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + org.apache.httpcomponents + httpmime + ${httpmime-version} + + + + + org.junit.jupiter + junit-jupiter-api + ${junit-version} + test + + + + + UTF-8 + 11 + 11 + 2.17.1 + 0.2.6 + 1.3.5 + 2.0.2 + 4.5.14 + 5.10.2 + 2.27.2 + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/settings.gradle b/samples/client/petstore/java/native/test-regenerated-fixed/settings.gradle new file mode 100644 index 000000000000..369ba54a9e06 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "openapi-java-client" \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/AndroidManifest.xml b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..54fbcb3da1e8 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiClient.java new file mode 100644 index 000000000000..9afcc9608abd --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiClient.java @@ -0,0 +1,457 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.jackson.nullable.JsonNullableModule; + +import java.io.InputStream; +import java.net.URI; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpConnectTimeoutException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static java.nio.charset.StandardCharsets.UTF_8; + +/** + * Configuration and utility class for API clients. + * + *

This class can be constructed and modified, then used to instantiate the + * various API classes. The API classes use the settings in this class to + * configure themselves, but otherwise do not store a link to this class.

+ * + *

This class is mutable and not synchronized, so it is not thread-safe. + * The API classes generated from this are immutable and thread-safe.

+ * + *

The setter methods of this class return the current object to facilitate + * a fluent style of configuration.

+ */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiClient { + + protected HttpClient.Builder builder; + protected ObjectMapper mapper; + protected String scheme; + protected String host; + protected int port; + protected String basePath; + protected Consumer interceptor; + protected Consumer> responseInterceptor; + protected Consumer> asyncResponseInterceptor; + protected Duration readTimeout; + protected Duration connectTimeout; + + public static String valueToString(Object value) { + if (value == null) { + return ""; + } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + return value.toString(); + } + + /** + * URL encode a string in the UTF-8 encoding. + * + * @param s String to encode. + * @return URL-encoded representation of the input string. + */ + public static String urlEncode(String s) { + return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20"); + } + + /** + * Convert a URL query name/value parameter to a list of encoded {@link Pair} + * objects. + * + *

The value can be null, in which case an empty list is returned.

+ * + * @param name The query name parameter. + * @param value The query value, which may not be a collection but may be + * null. + * @return A singleton list of the {@link Pair} objects representing the input + * parameters, which is encoded for use in a URL. If the value is null, an + * empty list is returned. + */ + public static List parameterToPairs(String name, Object value) { + if (name == null || name.isEmpty() || value == null) { + return Collections.emptyList(); + } + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); + } + + /** + * Convert a URL query name/collection parameter to a list of encoded + * {@link Pair} objects. + * + * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). + * @param name The query name parameter. + * @param values A collection of values for the given query name, which may be + * null. + * @return A list of {@link Pair} objects representing the input parameters, + * which is encoded for use in a URL. If the values collection is null, an + * empty list is returned. + */ + public static List parameterToPairs( + String collectionFormat, String name, Collection values) { + if (name == null || name.isEmpty() || values == null || values.isEmpty()) { + return Collections.emptyList(); + } + + // get the collection format (default: csv) + String format = collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; + + // create the params based on the collection format + if ("multi".equals(format)) { + return values.stream() + .map(value -> new Pair(urlEncode(name), urlEncode(valueToString(value)))) + .collect(Collectors.toList()); + } + + String delimiter; + switch(format) { + case "csv": + delimiter = urlEncode(","); + break; + case "ssv": + delimiter = urlEncode(" "); + break; + case "tsv": + delimiter = urlEncode("\t"); + break; + case "pipes": + delimiter = urlEncode("|"); + break; + default: + throw new IllegalArgumentException("Illegal collection format: " + collectionFormat); + } + + StringJoiner joiner = new StringJoiner(delimiter); + for (Object value : values) { + joiner.add(urlEncode(valueToString(value))); + } + + return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); + } + + /** + * Create an instance of ApiClient. + */ + public ApiClient() { + this.builder = createDefaultHttpClientBuilder(); + this.mapper = createDefaultObjectMapper(); + updateBaseUri(getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + /** + * Create an instance of ApiClient. + * + * @param builder Http client builder. + * @param mapper Object mapper. + * @param baseUri Base URI + */ + public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri) { + this.builder = builder; + this.mapper = mapper; + updateBaseUri(baseUri != null ? baseUri : getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + public static ObjectMapper createDefaultObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); + return mapper; + } + + protected String getDefaultBaseUri() { + return "http://petstore.swagger.io/v2"; + } + + public static HttpClient.Builder createDefaultHttpClientBuilder() { + return HttpClient.newBuilder(); + } + + public final void updateBaseUri(String baseUri) { + URI uri = URI.create(baseUri); + scheme = uri.getScheme(); + host = uri.getHost(); + port = uri.getPort(); + basePath = uri.getRawPath(); + } + + /** + * Set a custom {@link HttpClient.Builder} object to use when creating the + * {@link HttpClient} that is used by the API client. + * + * @param builder Custom client builder. + * @return This object. + */ + public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { + this.builder = builder; + return this; + } + + /** + * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. + * + *

The returned object is immutable and thread-safe.

+ * + * @return The HTTP client. + */ + public HttpClient getHttpClient() { + return builder.build(); + } + + /** + * Set a custom {@link ObjectMapper} to serialize and deserialize the request + * and response bodies. + * + * @param mapper Custom object mapper. + * @return This object. + */ + public ApiClient setObjectMapper(ObjectMapper mapper) { + this.mapper = mapper; + return this; + } + + /** + * Get a copy of the current {@link ObjectMapper}. + * + * @return A copy of the current object mapper. + */ + public ObjectMapper getObjectMapper() { + return mapper.copy(); + } + + /** + * Set a custom host name for the target service. + * + * @param host The host name of the target service. + * @return This object. + */ + public ApiClient setHost(String host) { + this.host = host; + return this; + } + + /** + * Set a custom port number for the target service. + * + * @param port The port of the target service. Set this to -1 to reset the + * value to the default for the scheme. + * @return This object. + */ + public ApiClient setPort(int port) { + this.port = port; + return this; + } + + /** + * Set a custom base path for the target service, for example '/v2'. + * + * @param basePath The base path against which the rest of the path is + * resolved. + * @return This object. + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get the base URI to resolve the endpoint paths against. + * + * @return The complete base URI that the rest of the API parameters are + * resolved against. + */ + public String getBaseUri() { + return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath; + } + + /** + * Set a custom scheme for the target service, for example 'https'. + * + * @param scheme The scheme of the target service + * @return This object. + */ + public ApiClient setScheme(String scheme){ + this.scheme = scheme; + return this; + } + + /** + * Set a custom request interceptor. + * + *

A request interceptor is a mechanism for altering each request before it + * is sent. After the request has been fully configured but not yet built, the + * request builder is passed into this function for further modification, + * after which it is sent out.

+ * + *

This is useful for altering the requests in a custom manner, such as + * adding headers. It could also be used for logging and monitoring.

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setRequestInterceptor(Consumer interceptor) { + this.interceptor = interceptor; + return this; + } + + /** + * Get the custom interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer getRequestInterceptor() { + return interceptor; + } + + /** + * Set a custom response interceptor. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setResponseInterceptor(Consumer> interceptor) { + this.responseInterceptor = interceptor; + return this; + } + + /** + * Get the custom response interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getResponseInterceptor() { + return responseInterceptor; + } + + /** + * Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { + this.asyncResponseInterceptor = interceptor; + return this; + } + + /** + * Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getAsyncResponseInterceptor() { + return asyncResponseInterceptor; + } + + /** + * Set the read timeout for the http client. + * + *

This is the value used by default for each request, though it can be + * overridden on a per-request basis with a request interceptor.

+ * + * @param readTimeout The read timeout used by default by the http client. + * Setting this value to null resets the timeout to an + * effectively infinite value. + * @return This object. + */ + public ApiClient setReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; + } + + /** + * Get the read timeout that was set. + * + * @return The read timeout, or null if no timeout was set. Null represents + * an infinite wait time. + */ + public Duration getReadTimeout() { + return readTimeout; + } + /** + * Sets the connect timeout (in milliseconds) for the http client. + * + *

In the case where a new connection needs to be established, if + * the connection cannot be established within the given {@code + * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler) + * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or + * {@link HttpClient#sendAsync(HttpRequest,BodyHandler) + * HttpClient::sendAsync} completes exceptionally with an + * {@code HttpConnectTimeoutException}. If a new connection does not + * need to be established, for example if a connection can be reused + * from a previous request, then this timeout duration has no effect. + * + * @param connectTimeout connection timeout in milliseconds + * + * @return This object. + */ + public ApiClient setConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + this.builder.connectTimeout(connectTimeout); + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public Duration getConnectTimeout() { + return connectTimeout; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiException.java new file mode 100644 index 000000000000..b2c796e41c45 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiException.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.net.http.HttpHeaders; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + + private int code = 0; + private HttpHeaders responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return Headers as an HttpHeaders object + */ + public HttpHeaders getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiResponse.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiResponse.java new file mode 100644 index 000000000000..dfaf2fc37f49 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ApiResponse.java @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/Configuration.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/Configuration.java new file mode 100644 index 000000000000..b7a6ebfcde4d --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/Configuration.java @@ -0,0 +1,63 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Configuration { + public static final String VERSION = "1.0.0"; + + private static final AtomicReference defaultApiClient = new AtomicReference<>(); + private static volatile Supplier apiClientFactory = ApiClient::new; + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + ApiClient client = defaultApiClient.get(); + if (client == null) { + client = defaultApiClient.updateAndGet(val -> { + if (val != null) { // changed by another thread + return val; + } + return apiClientFactory.get(); + }); + } + return client; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient.set(apiClient); + } + + /** + * set the callback used to create new ApiClient objects + */ + public static void setApiClientFactory(Supplier factory) { + apiClientFactory = Objects.requireNonNull(factory); + } + + private Configuration() { + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/JSON.java new file mode 100644 index 000000000000..7f6a0317ebc1 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/JSON.java @@ -0,0 +1,264 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import org.openapitools.jackson.nullable.JsonNullableModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.client.model.*; + +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = JsonMapper.builder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) + .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) + .defaultDateFormat(new RFC3339DateFormat()) + .addModule(new JavaTimeModule()) + .build(); + JsonNullableModule jnm = new JsonNullableModule(); + mapper.registerModule(jnm); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public ObjectMapper getMapper() { return mapper; } + + /** + * Returns the target model class that should be used to deserialize the input data. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + * + * @return the target model class. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** + * Helper class to register the discriminator mappings. + */ + @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. + * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + * + * @return the target model class. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, + * so it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + * @param visitedClasses The set of classes that have already been visited. + * + * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. + */ + public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map> descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (Class childType : descendants.values()) { + if (isInstanceOf(childType, inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** + * A map of discriminators for all model classes. + */ + private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); + + /** + * A map of oneOf/anyOf descendants for each model class. + */ + private static Map, Map>> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map> descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/Pair.java new file mode 100644 index 000000000000..121faebe0766 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/Pair.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pair { + private final String name; + private final String value; + + public Pair(String name, String value) { + this.name = isValidString(name) ? name : ""; + this.value = isValidString(value) ? value : ""; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private static boolean isValidString(String arg) { + return arg != null; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339DateFormat.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339DateFormat.java new file mode 100644 index 000000000000..791079ce6d83 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339DateFormat.java @@ -0,0 +1,58 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.text.DecimalFormat; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse(String source) { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return super.clone(); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 000000000000..248ff1a011ca --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + private static final long serialVersionUID = 1L; + private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault(); + private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + = JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault(); + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false, // keep zero offset and Z separate since zones explicitly supported + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ, + boolean normalizeZoneId, + boolean readNumericStringsAsTimestamp) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ, + normalizeZoneId, + readNumericStringsAsTimestamp + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 000000000000..53e5ca962811 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + private static final long serialVersionUID = 1L; + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ServerConfiguration.java new file mode 100644 index 000000000000..1f7afd0db9d9 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ServerConfiguration.java @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ServerVariable.java new file mode 100644 index 000000000000..dd7ada6e073e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/PetApi.java new file mode 100644 index 000000000000..aa3c05111881 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/PetApi.java @@ -0,0 +1,1110 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class PetApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public PetApi() { + this(Configuration.getDefaultApiClient()); + } + + public PetApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPet(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = addPetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPetWithHttpInfo(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("addPet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePet(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + deletePetWithHttpInfo(petId, apiKey, headers); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePetWithHttpInfo(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deletePet", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + if (apiKey != null) { + localVarRequestBuilder.header("api_key", apiKey.toString()); + } + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatus(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatusWithHttpInfo(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByStatus", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByStatus"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "status"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTags(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTagsWithHttpInfo(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByTags", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByTags"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "tags"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetById(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId, headers); + return localVarResponse.getData(); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetByIdWithHttpInfo(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getPetById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePet(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = updatePetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePetWithHttpInfo(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithForm(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + updatePetWithFormWithHttpInfo(petId, name, status, headers); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithFormWithHttpInfo(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePetWithForm", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + List formValues = new ArrayList<>(); + if (name != null) { + formValues.add(new BasicNameValuePair("name", name.toString())); + } + if (status != null) { + formValues.add(new BasicNameValuePair("status", status.toString())); + } + HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8); + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()))); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFile(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file, headers); + return localVarResponse.getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFileWithHttpInfo(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("uploadFile", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}/uploadImage" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create(); + boolean hasFiles = false; + if (additionalMetadata != null) { + multiPartBuilder.addTextBody("additionalMetadata", additionalMetadata.toString()); + } + multiPartBuilder.addBinaryBody("file", _file); + hasFiles = true; + HttpEntity entity = multiPartBuilder.build(); + HttpRequest.BodyPublisher formDataPublisher; + if (hasFiles) { + Pipe pipe; + try { + pipe = Pipe.open(); + } catch (IOException e) { + throw new RuntimeException(e); + } + new Thread(() -> { + try (OutputStream outputStream = Channels.newOutputStream(pipe.sink())) { + entity.writeTo(outputStream); + } catch (IOException e) { + e.printStackTrace(); + } + }).start(); + formDataPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> Channels.newInputStream(pipe.source())); + } else { + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + formDataPublisher = HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray())); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", formDataPublisher); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/StoreApi.java new file mode 100644 index 000000000000..f45c23d159a4 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/StoreApi.java @@ -0,0 +1,535 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import org.openapitools.client.model.Order; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class StoreApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public StoreApi() { + this(Configuration.getDefaultApiClient()); + } + + public StoreApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrder(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + deleteOrderWithHttpInfo(orderId, headers); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrderWithHttpInfo(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteOrder", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory() throws ApiException { + return getInventory(, null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory(Map headers) throws ApiException { + ApiResponse> localVarResponse = getInventoryWithHttpInfo(headers); + return localVarResponse.getData(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { + return getInventoryWithHttpInfo(, null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getInventory", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getInventoryRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/inventory"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderById(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId, headers); + return localVarResponse.getData(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderByIdWithHttpInfo(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getOrderById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrder(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + ApiResponse localVarResponse = placeOrderWithHttpInfo(order, headers); + return localVarResponse.getData(); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrderWithHttpInfo(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("placeOrder", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + // verify the required parameter 'order' is set + if (order == null) { + throw new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(order); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/UserApi.java new file mode 100644 index 000000000000..ea659b72e460 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/api/UserApi.java @@ -0,0 +1,995 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class UserApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public UserApi() { + this(Configuration.getDefaultApiClient()); + } + + public UserApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user) throws ApiException { + return createUser(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + createUserWithHttpInfo(user, headers); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user) throws ApiException { + return createUserWithHttpInfo(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithArrayInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithArrayInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithArray"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithListInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithListInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithList"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUser(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + deleteUserWithHttpInfo(username, headers); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUserWithHttpInfo(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByName(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + ApiResponse localVarResponse = getUserByNameWithHttpInfo(username, headers); + return localVarResponse.getData(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByNameWithHttpInfo(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getUserByName", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUser(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + ApiResponse localVarResponse = loginUserWithHttpInfo(username, password, headers); + return localVarResponse.getData(); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUserWithHttpInfo(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("loginUser", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); + } + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/login"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "username"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("username", username)); + localVarQueryParameterBaseName = "password"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("password", password)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs out current logged in user session + * + * @throws ApiException if fails to make API call + */ + public void logoutUser() throws ApiException { + return logoutUser(, null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void logoutUser(Map headers) throws ApiException { + logoutUserWithHttpInfo(headers); + } + + /** + * Logs out current logged in user session + * + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo() throws ApiException { + return logoutUserWithHttpInfo(, null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("logoutUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder logoutUserRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/logout"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUser(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + updateUserWithHttpInfo(username, user, headers); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUserWithHttpInfo(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updateUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); + } + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling updateUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000000..772e5e7c3c1b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.lang.reflect.Type; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Category.java new file mode 100644 index 000000000000..74d7fa10840a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Category.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A category for a pet + */ +@JsonPropertyOrder({ + Category.JSON_PROPERTY_ID, + Category.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Category { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Category() { + } + + public Category id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Category name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Category object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/ModelApiResponse.java new file mode 100644 index 000000000000..7b4850fa80af --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -0,0 +1,223 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * Describes the result of uploading an image resource + */ +@JsonPropertyOrder({ + ModelApiResponse.JSON_PROPERTY_CODE, + ModelApiResponse.JSON_PROPERTY_TYPE, + ModelApiResponse.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ModelApiResponse { + public static final String JSON_PROPERTY_CODE = "code"; + @javax.annotation.Nullable + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + @javax.annotation.Nullable + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + @javax.annotation.Nullable + private String message; + + public ModelApiResponse() { + } + + public ModelApiResponse code(@javax.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(@javax.annotation.Nullable Integer code) { + this.code = code; + } + + + public ModelApiResponse type(@javax.annotation.Nullable String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(@javax.annotation.Nullable String type) { + this.type = type; + } + + + public ModelApiResponse message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + /** + * Return true if this ApiResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format("%scode%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getCode())))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format("%stype%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getType())))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format("%smessage%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getMessage())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Order.java new file mode 100644 index 000000000000..4c48e61a5211 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Order.java @@ -0,0 +1,369 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.time.OffsetDateTime; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * An order for a pets from the pet store + */ +@JsonPropertyOrder({ + Order.JSON_PROPERTY_ID, + Order.JSON_PROPERTY_PET_ID, + Order.JSON_PROPERTY_QUANTITY, + Order.JSON_PROPERTY_SHIP_DATE, + Order.JSON_PROPERTY_STATUS, + Order.JSON_PROPERTY_COMPLETE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Order { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_PET_ID = "petId"; + @javax.annotation.Nullable + private Long petId; + + public static final String JSON_PROPERTY_QUANTITY = "quantity"; + @javax.annotation.Nullable + private Integer quantity; + + public static final String JSON_PROPERTY_SHIP_DATE = "shipDate"; + @javax.annotation.Nullable + private OffsetDateTime shipDate; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED(String.valueOf("placed")), + + APPROVED(String.valueOf("approved")), + + DELIVERED(String.valueOf("delivered")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public static final String JSON_PROPERTY_COMPLETE = "complete"; + @javax.annotation.Nullable + private Boolean complete = false; + + public Order() { + } + + public Order id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Order petId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getPetId() { + return petId; + } + + + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPetId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + } + + + public Order quantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getQuantity() { + return quantity; + } + + + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setQuantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + } + + + public Order shipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getShipDate() { + return shipDate; + } + + + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setShipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + } + + + public Order status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + public Order complete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getComplete() { + return complete; + } + + + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComplete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + } + + + /** + * Return true if this Order object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `petId` to the URL query string + if (getPetId() != null) { + joiner.add(String.format("%spetId%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPetId())))); + } + + // add `quantity` to the URL query string + if (getQuantity() != null) { + joiner.add(String.format("%squantity%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getQuantity())))); + } + + // add `shipDate` to the URL query string + if (getShipDate() != null) { + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getShipDate())))); + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + // add `complete` to the URL query string + if (getComplete() != null) { + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getComplete())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Pet.java new file mode 100644 index 000000000000..cc394c7afcae --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Pet.java @@ -0,0 +1,397 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A pet for sale in the pet store + */ +@JsonPropertyOrder({ + Pet.JSON_PROPERTY_ID, + Pet.JSON_PROPERTY_CATEGORY, + Pet.JSON_PROPERTY_NAME, + Pet.JSON_PROPERTY_PHOTO_URLS, + Pet.JSON_PROPERTY_TAGS, + Pet.JSON_PROPERTY_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pet { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_CATEGORY = "category"; + @javax.annotation.Nullable + private Category category; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nonnull + private String name; + + public static final String JSON_PROPERTY_PHOTO_URLS = "photoUrls"; + @javax.annotation.Nonnull + private List photoUrls = new ArrayList<>(); + + public static final String JSON_PROPERTY_TAGS = "tags"; + @javax.annotation.Nullable + private List tags = new ArrayList<>(); + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE(String.valueOf("available")), + + PENDING(String.valueOf("pending")), + + SOLD(String.valueOf("sold")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public Pet() { + } + + public Pet id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Pet category(@javax.annotation.Nullable Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Category getCategory() { + return category; + } + + + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCategory(@javax.annotation.Nullable Category category) { + this.category = category; + } + + + public Pet name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public Pet photoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + if (this.photoUrls == null) { + this.photoUrls = new ArrayList<>(); + } + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getPhotoUrls() { + return photoUrls; + } + + + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setPhotoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + } + + + public Pet tags(@javax.annotation.Nullable List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTags() { + return tags; + } + + + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTags(@javax.annotation.Nullable List tags) { + this.tags = tags; + } + + + public Pet status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + /** + * Return true if this Pet object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `category` to the URL query string + if (getCategory() != null) { + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + // add `photoUrls` to the URL query string + if (getPhotoUrls() != null) { + for (int i = 0; i < getPhotoUrls().size(); i++) { + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + ApiClient.urlEncode(ApiClient.valueToString(getPhotoUrls().get(i))))); + } + } + + // add `tags` to the URL query string + if (getTags() != null) { + for (int i = 0; i < getTags().size(); i++) { + if (getTags().get(i) != null) { + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Tag.java new file mode 100644 index 000000000000..be01bae3f7d2 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/Tag.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A tag for a pet + */ +@JsonPropertyOrder({ + Tag.JSON_PROPERTY_ID, + Tag.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Tag { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Tag() { + } + + public Tag id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Tag name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Tag object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/User.java new file mode 100644 index 000000000000..b2b2ab12cd05 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/main/java/org/openapitools/client/model/User.java @@ -0,0 +1,403 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A User who is purchasing from the pet store + */ +@JsonPropertyOrder({ + User.JSON_PROPERTY_ID, + User.JSON_PROPERTY_USERNAME, + User.JSON_PROPERTY_FIRST_NAME, + User.JSON_PROPERTY_LAST_NAME, + User.JSON_PROPERTY_EMAIL, + User.JSON_PROPERTY_PASSWORD, + User.JSON_PROPERTY_PHONE, + User.JSON_PROPERTY_USER_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:07:41.448223+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class User { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_USERNAME = "username"; + @javax.annotation.Nullable + private String username; + + public static final String JSON_PROPERTY_FIRST_NAME = "firstName"; + @javax.annotation.Nullable + private String firstName; + + public static final String JSON_PROPERTY_LAST_NAME = "lastName"; + @javax.annotation.Nullable + private String lastName; + + public static final String JSON_PROPERTY_EMAIL = "email"; + @javax.annotation.Nullable + private String email; + + public static final String JSON_PROPERTY_PASSWORD = "password"; + @javax.annotation.Nullable + private String password; + + public static final String JSON_PROPERTY_PHONE = "phone"; + @javax.annotation.Nullable + private String phone; + + public static final String JSON_PROPERTY_USER_STATUS = "userStatus"; + @javax.annotation.Nullable + private Integer userStatus; + + public User() { + } + + public User id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public User username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUsername() { + return username; + } + + + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + + public User firstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstName() { + return firstName; + } + + + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + } + + + public User lastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLastName() { + return lastName; + } + + + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + } + + + public User email(@javax.annotation.Nullable String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEmail() { + return email; + } + + + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEmail(@javax.annotation.Nullable String email) { + this.email = email; + } + + + public User password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPassword() { + return password; + } + + + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + + public User phone(@javax.annotation.Nullable String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPhone() { + return phone; + } + + + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPhone(@javax.annotation.Nullable String phone) { + this.phone = phone; + } + + + public User userStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getUserStatus() { + return userStatus; + } + + + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUserStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + } + + + /** + * Return true if this User object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `username` to the URL query string + if (getUsername() != null) { + joiner.add(String.format("%susername%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUsername())))); + } + + // add `firstName` to the URL query string + if (getFirstName() != null) { + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getFirstName())))); + } + + // add `lastName` to the URL query string + if (getLastName() != null) { + joiner.add(String.format("%slastName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getLastName())))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add(String.format("%semail%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getEmail())))); + } + + // add `password` to the URL query string + if (getPassword() != null) { + joiner.add(String.format("%spassword%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPassword())))); + } + + // add `phone` to the URL query string + if (getPhone() != null) { + joiner.add(String.format("%sphone%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPhone())))); + } + + // add `userStatus` to the URL query string + if (getUserStatus() != null) { + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUserStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/PetApiTest.java new file mode 100644 index 000000000000..f725ba246938 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -0,0 +1,180 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for PetApi + */ +@Disabled +public class PetApiTest { + + private final PetApi api = new PetApi(); + + + /** + * Add a new pet to the store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void addPetTest() throws ApiException { + Pet pet = null; + Pet response = + api.addPet(pet); + + // TODO: test validations + } + + /** + * Deletes a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deletePetTest() throws ApiException { + Long petId = null; + String apiKey = null; + + api.deletePet(petId, apiKey); + + // TODO: test validations + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByStatusTest() throws ApiException { + List status = null; + List response = + api.findPetsByStatus(status); + + // TODO: test validations + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByTagsTest() throws ApiException { + List tags = null; + List response = + api.findPetsByTags(tags); + + // TODO: test validations + } + + /** + * Find pet by ID + * + * Returns a single pet + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getPetByIdTest() throws ApiException { + Long petId = null; + Pet response = + api.getPetById(petId); + + // TODO: test validations + } + + /** + * Update an existing pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetTest() throws ApiException { + Pet pet = null; + Pet response = + api.updatePet(pet); + + // TODO: test validations + } + + /** + * Updates a pet in the store with form data + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetWithFormTest() throws ApiException { + Long petId = null; + String name = null; + String status = null; + + api.updatePetWithForm(petId, name, status); + + // TODO: test validations + } + + /** + * uploads an image + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileTest() throws ApiException { + Long petId = null; + String additionalMetadata = null; + File _file = null; + ModelApiResponse response = + api.uploadFile(petId, additionalMetadata, _file); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/StoreApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/StoreApiTest.java new file mode 100644 index 000000000000..be318cab8b1e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/StoreApiTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import org.openapitools.client.model.Order; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for StoreApi + */ +@Disabled +public class StoreApiTest { + + private final StoreApi api = new StoreApi(); + + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteOrderTest() throws ApiException { + String orderId = null; + + api.deleteOrder(orderId); + + // TODO: test validations + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getInventoryTest() throws ApiException { + Map response = + api.getInventory(); + + // TODO: test validations + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getOrderByIdTest() throws ApiException { + Long orderId = null; + Order response = + api.getOrderById(orderId); + + // TODO: test validations + } + + /** + * Place an order for a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void placeOrderTest() throws ApiException { + Order order = null; + Order response = + api.placeOrder(order); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/UserApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/UserApiTest.java new file mode 100644 index 000000000000..2b2b7a60fd21 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/api/UserApiTest.java @@ -0,0 +1,175 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for UserApi + */ +@Disabled +public class UserApiTest { + + private final UserApi api = new UserApi(); + + + /** + * Create user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUserTest() throws ApiException { + User user = null; + + api.createUser(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() throws ApiException { + List user = null; + + api.createUsersWithArrayInput(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() throws ApiException { + List user = null; + + api.createUsersWithListInput(user); + + // TODO: test validations + } + + /** + * Delete user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteUserTest() throws ApiException { + String username = null; + + api.deleteUser(username); + + // TODO: test validations + } + + /** + * Get user by user name + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserByNameTest() throws ApiException { + String username = null; + User response = + api.getUserByName(username); + + // TODO: test validations + } + + /** + * Logs user into the system + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void loginUserTest() throws ApiException { + String username = null; + String password = null; + String response = + api.loginUser(username, password); + + // TODO: test validations + } + + /** + * Logs out current logged in user session + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void logoutUserTest() throws ApiException { + + api.logoutUser(); + + // TODO: test validations + } + + /** + * Updated user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserTest() throws ApiException { + String username = null; + User user = null; + + api.updateUser(username, user); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/CategoryTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/CategoryTest.java new file mode 100644 index 000000000000..ae23ab433a50 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/CategoryTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Category + */ +class CategoryTest { + private final Category model = new Category(); + + /** + * Model tests for Category + */ + @Test + void testCategory() { + // TODO: test Category + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java new file mode 100644 index 000000000000..c846563bfe1f --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java @@ -0,0 +1,64 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ModelApiResponse + */ +class ModelApiResponseTest { + private final ModelApiResponse model = new ModelApiResponse(); + + /** + * Model tests for ModelApiResponse + */ + @Test + void testModelApiResponse() { + // TODO: test ModelApiResponse + } + + /** + * Test the property 'code' + */ + @Test + void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + void messageTest() { + // TODO: test message + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/OrderTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/OrderTest.java new file mode 100644 index 000000000000..4d8d136809eb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/OrderTest.java @@ -0,0 +1,89 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Order + */ +class OrderTest { + private final Order model = new Order(); + + /** + * Model tests for Order + */ + @Test + void testOrder() { + // TODO: test Order + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'petId' + */ + @Test + void petIdTest() { + // TODO: test petId + } + + /** + * Test the property 'quantity' + */ + @Test + void quantityTest() { + // TODO: test quantity + } + + /** + * Test the property 'shipDate' + */ + @Test + void shipDateTest() { + // TODO: test shipDate + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + + /** + * Test the property 'complete' + */ + @Test + void completeTest() { + // TODO: test complete + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/PetTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/PetTest.java new file mode 100644 index 000000000000..84aff8adbf96 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/PetTest.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Pet + */ +class PetTest { + private final Pet model = new Pet(); + + /** + * Model tests for Pet + */ + @Test + void testPet() { + // TODO: test Pet + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'category' + */ + @Test + void categoryTest() { + // TODO: test category + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'photoUrls' + */ + @Test + void photoUrlsTest() { + // TODO: test photoUrls + } + + /** + * Test the property 'tags' + */ + @Test + void tagsTest() { + // TODO: test tags + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/TagTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/TagTest.java new file mode 100644 index 000000000000..6bd8b9f5035e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/TagTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Tag + */ +class TagTest { + private final Tag model = new Tag(); + + /** + * Model tests for Tag + */ + @Test + void testTag() { + // TODO: test Tag + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/UserTest.java b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/UserTest.java new file mode 100644 index 000000000000..40f4892264aa --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed/src/test/java/org/openapitools/client/model/UserTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for User + */ +class UserTest { + private final User model = new User(); + + /** + * Model tests for User + */ + @Test + void testUser() { + // TODO: test User + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'username' + */ + @Test + void usernameTest() { + // TODO: test username + } + + /** + * Test the property 'firstName' + */ + @Test + void firstNameTest() { + // TODO: test firstName + } + + /** + * Test the property 'lastName' + */ + @Test + void lastNameTest() { + // TODO: test lastName + } + + /** + * Test the property 'email' + */ + @Test + void emailTest() { + // TODO: test email + } + + /** + * Test the property 'password' + */ + @Test + void passwordTest() { + // TODO: test password + } + + /** + * Test the property 'phone' + */ + @Test + void phoneTest() { + // TODO: test phone + } + + /** + * Test the property 'userStatus' + */ + @Test + void userStatusTest() { + // TODO: test userStatus + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/.github/workflows/maven.yml b/samples/client/petstore/java/native/test-regenerated-fixed2/.github/workflows/maven.yml new file mode 100644 index 000000000000..460f78bfd1b2 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/.github/workflows/maven.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build OpenAPI Petstore + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 17, 21 ] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/.gitignore b/samples/client/petstore/java/native/test-regenerated-fixed2/.gitignore new file mode 100644 index 000000000000..a530464afa1b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/.gitignore @@ -0,0 +1,21 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator-ignore b/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator/FILES b/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator/FILES new file mode 100644 index 000000000000..57d506c4c50b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator/FILES @@ -0,0 +1,56 @@ +.github/workflows/maven.yml +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +build.gradle +build.sbt +docs/Category.md +docs/ModelApiResponse.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +git_push.sh +gradle.properties +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/AndroidManifest.xml +src/main/java/org/openapitools/client/ApiClient.java +src/main/java/org/openapitools/client/ApiException.java +src/main/java/org/openapitools/client/ApiResponse.java +src/main/java/org/openapitools/client/Configuration.java +src/main/java/org/openapitools/client/JSON.java +src/main/java/org/openapitools/client/Pair.java +src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java +src/main/java/org/openapitools/client/ServerConfiguration.java +src/main/java/org/openapitools/client/ServerVariable.java +src/main/java/org/openapitools/client/api/PetApi.java +src/main/java/org/openapitools/client/api/StoreApi.java +src/main/java/org/openapitools/client/api/UserApi.java +src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java +src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ModelApiResponse.java +src/main/java/org/openapitools/client/model/Order.java +src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Tag.java +src/main/java/org/openapitools/client/model/User.java +src/test/java/org/openapitools/client/api/PetApiTest.java +src/test/java/org/openapitools/client/api/StoreApiTest.java +src/test/java/org/openapitools/client/api/UserApiTest.java +src/test/java/org/openapitools/client/model/CategoryTest.java +src/test/java/org/openapitools/client/model/ModelApiResponseTest.java +src/test/java/org/openapitools/client/model/OrderTest.java +src/test/java/org/openapitools/client/model/PetTest.java +src/test/java/org/openapitools/client/model/TagTest.java +src/test/java/org/openapitools/client/model/UserTest.java diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator/VERSION b/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator/VERSION new file mode 100644 index 000000000000..fc74d6ceba8e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.15.0-SNAPSHOT diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/.travis.yml b/samples/client/petstore/java/native/test-regenerated-fixed2/.travis.yml new file mode 100644 index 000000000000..c94647479234 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/.travis.yml @@ -0,0 +1,16 @@ +# +# Generated by: https://openapi-generator.tech +# +language: java +jdk: + - oraclejdk11 +before_install: + # ensure gradlew has proper permission + - chmod a+x ./gradlew +script: + # test using maven + - mvn test + # uncomment below to test using gradle + # - gradle test + # uncomment below to test using sbt + # - sbt test diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/README.md b/samples/client/petstore/java/native/test-regenerated-fixed2/README.md new file mode 100644 index 000000000000..58ca90dfb57f --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/README.md @@ -0,0 +1,197 @@ +# openapi-java-client + +OpenAPI Petstore + +- API version: 1.0.0 + +- Build date: 2025-07-08T21:08:28.986952+07:00[Asia/Bangkok] + +- Generator version: 7.15.0-SNAPSHOT + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + +## Requirements + +Building the API client library requires: + +1. Java 11+ +2. Maven/Gradle + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn clean deploy +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + org.openapitools + openapi-java-client + 1.0.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "org.openapitools:openapi-java-client:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +- `target/openapi-java-client-1.0.0.jar` +- `target/lib/*.jar` + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import org.openapitools.client.*; +import org.openapitools.client.model.*; +import org.openapitools.client.api.PetApi; + +public class PetApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + // Configure clients using the `defaultClient` object, such as + // overriding the host and port, timeout, etc. + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetWithHttpInfo**](docs/PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**deletePetWithHttpInfo**](docs/PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByStatusWithHttpInfo**](docs/PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**findPetsByTagsWithHttpInfo**](docs/PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**getPetByIdWithHttpInfo**](docs/PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithHttpInfo**](docs/PetApi.md#updatePetWithHttpInfo) | **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* | [**updatePetWithFormWithHttpInfo**](docs/PetApi.md#updatePetWithFormWithHttpInfo) | **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* | [**uploadFileWithHttpInfo**](docs/PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**deleteOrderWithHttpInfo**](docs/StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryWithHttpInfo**](docs/StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**getOrderByIdWithHttpInfo**](docs/StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*StoreApi* | [**placeOrderWithHttpInfo**](docs/StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUserWithHttpInfo**](docs/UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithArrayInputWithHttpInfo**](docs/UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**createUsersWithListInputWithHttpInfo**](docs/UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**deleteUserWithHttpInfo**](docs/UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**getUserByNameWithHttpInfo**](docs/UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**loginUserWithHttpInfo**](docs/UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**logoutUserWithHttpInfo**](docs/UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user +*UserApi* | [**updateUserWithHttpInfo**](docs/UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Category](docs/Category.md) + - [ModelApiResponse](docs/ModelApiResponse.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### petstore_auth + + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + + +### api_key + + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. +However, the instances of the api clients created from the `ApiClient` are thread-safe and can be re-used. + +## Author + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/api/openapi.yaml b/samples/client/petstore/java/native/test-regenerated-fixed2/api/openapi.yaml new file mode 100644 index 000000000000..9b1b54b9454b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/api/openapi.yaml @@ -0,0 +1,865 @@ +openapi: 3.0.0 +info: + description: "This is a sample server Petstore server. For this sample, you can\ + \ use the api key `special-key` to test the authorization filters." + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://petstore.swagger.io/v2 +tags: +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user +paths: + /pet: + post: + description: "" + operationId: addPet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + put: + description: "" + operationId: updatePet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + "405": + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /pet/findByStatus: + get: + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - description: Status values that need to be considered for filter + explode: false + in: query + name: status + required: true + schema: + items: + default: available + enum: + - available + - pending + - sold + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid status value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by status + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/findByTags: + get: + deprecated: true + description: "Multiple tags can be provided with comma separated strings. Use\ + \ tag1, tag2, tag3 for testing." + operationId: findPetsByTags + parameters: + - description: Tags to filter by + explode: false + in: query + name: tags + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid tag value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/{petId}: + delete: + description: "" + operationId: deletePet + parameters: + - explode: false + in: header + name: api_key + required: false + schema: + type: string + style: simple + - description: Pet id to delete + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "400": + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet + tags: + - pet + x-accepts: + - application/json + get: + description: Returns a single pet + operationId: getPetById + parameters: + - description: ID of pet to return + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: + - application/json + - application/xml + post: + description: "" + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/updatePetWithForm_request" + responses: + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-content-type: application/x-www-form-urlencoded + x-accepts: + - application/json + /pet/{petId}/uploadImage: + post: + description: "" + operationId: uploadFile + 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/uploadFile_request" + 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 + x-content-type: multipart/form-data + x-accepts: + - application/json + /store/inventory: + get: + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + "200": + content: + application/json: + schema: + additionalProperties: + format: int32 + type: integer + type: object + description: successful operation + security: + - api_key: [] + summary: Returns pet inventories by status + tags: + - store + x-accepts: + - application/json + /store/order: + post: + description: "" + operationId: placeOrder + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Order" + description: order placed for purchasing the pet + required: true + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /store/order/{orderId}: + delete: + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - description: ID of the order that needs to be deleted + explode: false + in: path + name: orderId + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Delete purchase order by ID + tags: + - store + x-accepts: + - application/json + get: + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generate exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + explode: false + in: path + name: orderId + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Find purchase order by ID + tags: + - store + x-accepts: + - application/json + - application/xml + /user: + post: + description: This can only be done by the logged in user. + operationId: createUser + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Created user object + required: true + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Create user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithArray: + post: + description: "" + operationId: createUsersWithArrayInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithList: + post: + description: "" + operationId: createUsersWithListInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/login: + get: + description: "" + operationId: loginUser + parameters: + - description: The user name for login + explode: true + in: query + name: username + required: true + schema: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + style: form + - description: The password for login in clear text + explode: true + in: query + name: password + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + Set-Cookie: + description: Cookie authentication key for use with the `api_key` apiKey + authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple + X-Rate-Limit: + description: calls per hour allowed by the user + explode: false + schema: + format: int32 + type: integer + style: simple + X-Expires-After: + description: date in UTC when token expires + explode: false + schema: + format: date-time + type: string + style: simple + "400": + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: + - application/json + - application/xml + /user/logout: + get: + description: "" + operationId: logoutUser + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Logs out current logged in user session + tags: + - user + x-accepts: + - application/json + /user/{username}: + delete: + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - description: The name that needs to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid username supplied + "404": + description: User not found + security: + - api_key: [] + summary: Delete user + tags: + - user + x-accepts: + - application/json + get: + description: "" + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/User" + application/json: + schema: + $ref: "#/components/schemas/User" + description: successful operation + "400": + description: Invalid username supplied + "404": + description: User not found + summary: Get user by user name + tags: + - user + x-accepts: + - application/json + - application/xml + put: + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - description: name that need to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Updated user object + required: true + responses: + "400": + description: Invalid user supplied + "404": + description: User not found + security: + - api_key: [] + summary: Updated user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json +components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: "#/components/schemas/User" + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + application/xml: + schema: + $ref: "#/components/schemas/Pet" + description: Pet object that needs to be added to the store + required: true + schemas: + ApiResponse: + description: Describes the result of uploading an image resource + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + title: An uploaded response + type: object + Pet: + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + category: + $ref: "#/components/schemas/Category" + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: "#/components/schemas/Tag" + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + title: a Pet + type: object + xml: + name: Pet + Order: + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + title: Pet Order + type: object + xml: + name: Order + User: + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + description: User Status + format: int32 + type: integer + title: a User + type: object + xml: + name: User + Category: + description: A category for a pet + example: + name: name + id: 6 + properties: + id: + format: int64 + type: integer + name: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + title: Pet category + type: object + xml: + name: Category + Tag: + description: A tag for a pet + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + title: Pet Tag + type: object + xml: + name: Tag + updatePetWithForm_request: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + uploadFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object + securitySchemes: + petstore_auth: + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + type: oauth2 + api_key: + in: header + name: api_key + type: apiKey + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/build.gradle b/samples/client/petstore/java/native/test-regenerated-fixed2/build.gradle new file mode 100644 index 000000000000..56fa470fb767 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/build.gradle @@ -0,0 +1,109 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'com.diffplug.spotless' + +group = 'org.openapitools' +version = '1.0.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} + +apply plugin: 'java' +apply plugin: 'maven-publish' + +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 + +// Some text from the schema is copy pasted into the source files as UTF-8 +// but the default still seems to be to use platform encoding +tasks.withType(JavaCompile) { + configure(options) { + options.encoding = 'UTF-8' + } +} +javadoc { + options.encoding = 'UTF-8' +} + +publishing { + publications { + maven(MavenPublication) { + artifactId = 'openapi-java-client' + from components.java + } + } +} + +task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath +} + +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + + +ext { + jackson_version = "2.17.1" + jakarta_annotation_version = "1.3.5" + beanvalidation_version = "2.0.2" + junit_version = "5.10.2" + httpmime_version = "4.5.13" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" + implementation "org.openapitools:jackson-databind-nullable:0.2.1" + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + implementation "org.apache.httpcomponents:httpmime:$httpmime_version" + testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + removeUnusedImports() + importOrder() + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/build.sbt b/samples/client/petstore/java/native/test-regenerated-fixed2/build.sbt new file mode 100644 index 000000000000..464090415c47 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/build.sbt @@ -0,0 +1 @@ +# TODO diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Category.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Category.md new file mode 100644 index 000000000000..a7fc939d252e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Category.md @@ -0,0 +1,15 @@ + + +# Category + +A category for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/ModelApiResponse.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/ModelApiResponse.md new file mode 100644 index 000000000000..cd7e3c400be6 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/ModelApiResponse.md @@ -0,0 +1,16 @@ + + +# ModelApiResponse + +Describes the result of uploading an image resource + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Order.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Order.md new file mode 100644 index 000000000000..0c33059b8b6a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Order.md @@ -0,0 +1,29 @@ + + +# Order + +An order for a pets from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**petId** | **Long** | | [optional] | +|**quantity** | **Integer** | | [optional] | +|**shipDate** | **OffsetDateTime** | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] | +|**complete** | **Boolean** | | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| PLACED | "placed" | +| APPROVED | "approved" | +| DELIVERED | "delivered" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Pet.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Pet.md new file mode 100644 index 000000000000..8bb363301232 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Pet.md @@ -0,0 +1,29 @@ + + +# Pet + +A pet for sale in the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**category** | [**Category**](Category.md) | | [optional] | +|**name** | **String** | | | +|**photoUrls** | **List<String>** | | | +|**tags** | [**List<Tag>**](Tag.md) | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| AVAILABLE | "available" | +| PENDING | "pending" | +| SOLD | "sold" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/PetApi.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/PetApi.md new file mode 100644 index 000000000000..51f089e85389 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/PetApi.md @@ -0,0 +1,1212 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store | +| [**addPetWithHttpInfo**](PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store | +| [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet | +| [**deletePetWithHttpInfo**](PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet | +| [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByStatusWithHttpInfo**](PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags | +| [**findPetsByTagsWithHttpInfo**](PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags | +| [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID | +| [**getPetByIdWithHttpInfo**](PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID | +| [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet | +| [**updatePetWithHttpInfo**](PetApi.md#updatePetWithHttpInfo) | **PUT** /pet | Update an existing pet | +| [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**updatePetWithFormWithHttpInfo**](PetApi.md#updatePetWithFormWithHttpInfo) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image | +| [**uploadFileWithHttpInfo**](PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image | + + + +## addPet + +> Pet addPet(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + +## addPetWithHttpInfo + +> ApiResponse addPet addPetWithHttpInfo(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.addPetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + + +## deletePet + +> void deletePet(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + apiInstance.deletePet(petId, apiKey); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + +## deletePetWithHttpInfo + +> ApiResponse deletePet deletePetWithHttpInfo(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + ApiResponse response = apiInstance.deletePetWithHttpInfo(petId, apiKey); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + + +## findPetsByStatus + +> List findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + List result = apiInstance.findPetsByStatus(status); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + +## findPetsByStatusWithHttpInfo + +> ApiResponse> findPetsByStatus findPetsByStatusWithHttpInfo(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + ApiResponse> response = apiInstance.findPetsByStatusWithHttpInfo(status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + + +## findPetsByTags + +> List findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + List result = apiInstance.findPetsByTags(tags); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + +## findPetsByTagsWithHttpInfo + +> ApiResponse> findPetsByTags findPetsByTagsWithHttpInfo(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + ApiResponse> response = apiInstance.findPetsByTagsWithHttpInfo(tags); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + + +## getPetById + +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + Pet result = apiInstance.getPetById(petId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +## getPetByIdWithHttpInfo + +> ApiResponse getPetById getPetByIdWithHttpInfo(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + ApiResponse response = apiInstance.getPetByIdWithHttpInfo(petId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + + +## updatePet + +> Pet updatePet(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.updatePet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + +## updatePetWithHttpInfo + +> ApiResponse updatePet updatePetWithHttpInfo(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.updatePetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + + +## updatePetWithForm + +> void updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + apiInstance.updatePetWithForm(petId, name, status); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +## updatePetWithFormWithHttpInfo + +> ApiResponse updatePetWithForm updatePetWithFormWithHttpInfo(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + ApiResponse response = apiInstance.updatePetWithFormWithHttpInfo(petId, name, status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + + +## uploadFile + +> ModelApiResponse uploadFile(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, _file); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +[**ModelApiResponse**](ModelApiResponse.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 | - | + +## uploadFileWithHttpInfo + +> ApiResponse uploadFile uploadFileWithHttpInfo(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ApiResponse response = apiInstance.uploadFileWithHttpInfo(petId, additionalMetadata, _file); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +ApiResponse<[**ModelApiResponse**](ModelApiResponse.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 | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/StoreApi.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/StoreApi.md new file mode 100644 index 000000000000..7dfbbe315c11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/StoreApi.md @@ -0,0 +1,564 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**deleteOrderWithHttpInfo**](StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status | +| [**getInventoryWithHttpInfo**](StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status | +| [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**getOrderByIdWithHttpInfo**](StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet | +| [**placeOrderWithHttpInfo**](StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet | + + + +## deleteOrder + +> void deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + apiInstance.deleteOrder(orderId); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## deleteOrderWithHttpInfo + +> ApiResponse deleteOrder deleteOrderWithHttpInfo(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + ApiResponse response = apiInstance.deleteOrderWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## getInventory + +> Map getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + Map result = apiInstance.getInventory(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**Map<String, Integer>** + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +## getInventoryWithHttpInfo + +> ApiResponse> getInventory getInventoryWithHttpInfo() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + ApiResponse> response = apiInstance.getInventoryWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +ApiResponse<**Map<String, Integer>**> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + +## getOrderById + +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + Order result = apiInstance.getOrderById(orderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## getOrderByIdWithHttpInfo + +> ApiResponse getOrderById getOrderByIdWithHttpInfo(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + ApiResponse response = apiInstance.getOrderByIdWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## placeOrder + +> Order placeOrder(order) + +Place an order for a pet + + + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + Order result = apiInstance.placeOrder(order); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + +## placeOrderWithHttpInfo + +> ApiResponse placeOrder placeOrderWithHttpInfo(order) + +Place an order for a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + ApiResponse response = apiInstance.placeOrderWithHttpInfo(order); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Tag.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Tag.md new file mode 100644 index 000000000000..abfde4afb501 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/Tag.md @@ -0,0 +1,15 @@ + + +# Tag + +A tag for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/User.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/User.md new file mode 100644 index 000000000000..426845227bd3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/User.md @@ -0,0 +1,21 @@ + + +# User + +A User who is purchasing from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**username** | **String** | | [optional] | +|**firstName** | **String** | | [optional] | +|**lastName** | **String** | | [optional] | +|**email** | **String** | | [optional] | +|**password** | **String** | | [optional] | +|**phone** | **String** | | [optional] | +|**userStatus** | **Integer** | User Status | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/docs/UserApi.md b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/UserApi.md new file mode 100644 index 000000000000..da72405c908b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/docs/UserApi.md @@ -0,0 +1,1178 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**createUser**](UserApi.md#createUser) | **POST** /user | Create user | +| [**createUserWithHttpInfo**](UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user | +| [**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithArrayInputWithHttpInfo**](UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array | +| [**createUsersWithListInputWithHttpInfo**](UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array | +| [**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user | +| [**deleteUserWithHttpInfo**](UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user | +| [**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name | +| [**getUserByNameWithHttpInfo**](UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name | +| [**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system | +| [**loginUserWithHttpInfo**](UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system | +| [**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session | +| [**logoutUserWithHttpInfo**](UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session | +| [**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user | +| [**updateUserWithHttpInfo**](UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user | + + + +## createUser + +> void createUser(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + apiInstance.createUser(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUserWithHttpInfo + +> ApiResponse createUser createUserWithHttpInfo(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + ApiResponse response = apiInstance.createUserWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithArrayInput + +> void createUsersWithArrayInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithArrayInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithArrayInputWithHttpInfo + +> ApiResponse createUsersWithArrayInput createUsersWithArrayInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithArrayInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithListInput + +> void createUsersWithListInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithListInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithListInputWithHttpInfo + +> ApiResponse createUsersWithListInput createUsersWithListInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithListInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## deleteUser + +> void deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + apiInstance.deleteUser(username); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## deleteUserWithHttpInfo + +> ApiResponse deleteUser deleteUserWithHttpInfo(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + ApiResponse response = apiInstance.deleteUserWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## getUserByName + +> User getUserByName(username) + +Get user by user name + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + User result = apiInstance.getUserByName(username); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +[**User**](User.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## getUserByNameWithHttpInfo + +> ApiResponse getUserByName getUserByNameWithHttpInfo(username) + +Get user by user name + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + ApiResponse response = apiInstance.getUserByNameWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +ApiResponse<[**User**](User.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## loginUser + +> String loginUser(username, password) + +Logs user into the system + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + String result = apiInstance.loginUser(username, password); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +**String** + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + +## loginUserWithHttpInfo + +> ApiResponse loginUser loginUserWithHttpInfo(username, password) + +Logs user into the system + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + ApiResponse response = apiInstance.loginUserWithHttpInfo(username, password); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +ApiResponse<**String**> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + + +## logoutUser + +> void logoutUser() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + apiInstance.logoutUser(); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## logoutUserWithHttpInfo + +> ApiResponse logoutUser logoutUserWithHttpInfo() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + ApiResponse response = apiInstance.logoutUserWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## updateUser + +> void updateUser(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + apiInstance.updateUser(username, user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + +## updateUserWithHttpInfo + +> ApiResponse updateUser updateUserWithHttpInfo(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + ApiResponse response = apiInstance.updateUserWithHttpInfo(username, user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/git_push.sh b/samples/client/petstore/java/native/test-regenerated-fixed2/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/gradle.properties b/samples/client/petstore/java/native/test-regenerated-fixed2/gradle.properties new file mode 100644 index 000000000000..a3408578278a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/gradle.properties @@ -0,0 +1,6 @@ +# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/java/native/test-regenerated-fixed2/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..e6441136f3d4 Binary files /dev/null and b/samples/client/petstore/java/native/test-regenerated-fixed2/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/java/native/test-regenerated-fixed2/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..b82aa23a4f05 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/gradlew b/samples/client/petstore/java/native/test-regenerated-fixed2/gradlew new file mode 100644 index 000000000000..9d0ce634cb11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/gradlew.bat b/samples/client/petstore/java/native/test-regenerated-fixed2/gradlew.bat new file mode 100644 index 000000000000..25da30dbdeee --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/pom.xml b/samples/client/petstore/java/native/test-regenerated-fixed2/pom.xml new file mode 100644 index 000000000000..10a3beca26fb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/pom.xml @@ -0,0 +1,264 @@ + + 4.0.0 + org.openapitools + openapi-java-client + jar + openapi-java-client + 1.0.0 + https://github.com/openapitools/openapi-generator + OpenAPI Java + + scm:git:git@github.com:openapitools/openapi-generator.git + scm:git:git@github.com:openapitools/openapi-generator.git + https://github.com/openapitools/openapi-generator + + + + + Unlicense + https://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + + OpenAPI-Generator Contributors + team@openapitools.org + OpenAPITools.org + http://openapitools.org + + + + + + + maven-enforcer-plugin + 3.1.0 + + + enforce-maven + + enforce + + + + + 3 + + + 11 + + + + + + + + maven-surefire-plugin + 3.2.5 + + + conf/log4j.properties + + -Xms512m -Xmx1500m + methods + 10 + + + + maven-dependency-plugin + 3.3.0 + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + test-jar + + + + + + + + maven-compiler-plugin + 3.10.1 + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.4.1 + + + attach-javadocs + + jar + + + + + + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + + + + .gitignore + + + + + + true + 4 + + + + + + + + + + 1.8 + + true + + + + + + + + + + + + sign-artifacts + + + + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + org.apache.httpcomponents + httpmime + ${httpmime-version} + + + + + org.junit.jupiter + junit-jupiter-api + ${junit-version} + test + + + + + UTF-8 + 11 + 11 + 2.17.1 + 0.2.6 + 1.3.5 + 2.0.2 + 4.5.14 + 5.10.2 + 2.27.2 + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/settings.gradle b/samples/client/petstore/java/native/test-regenerated-fixed2/settings.gradle new file mode 100644 index 000000000000..369ba54a9e06 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "openapi-java-client" \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/AndroidManifest.xml b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..54fbcb3da1e8 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiClient.java new file mode 100644 index 000000000000..35de9dbe844b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiClient.java @@ -0,0 +1,457 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.jackson.nullable.JsonNullableModule; + +import java.io.InputStream; +import java.net.URI; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpConnectTimeoutException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static java.nio.charset.StandardCharsets.UTF_8; + +/** + * Configuration and utility class for API clients. + * + *

This class can be constructed and modified, then used to instantiate the + * various API classes. The API classes use the settings in this class to + * configure themselves, but otherwise do not store a link to this class.

+ * + *

This class is mutable and not synchronized, so it is not thread-safe. + * The API classes generated from this are immutable and thread-safe.

+ * + *

The setter methods of this class return the current object to facilitate + * a fluent style of configuration.

+ */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiClient { + + protected HttpClient.Builder builder; + protected ObjectMapper mapper; + protected String scheme; + protected String host; + protected int port; + protected String basePath; + protected Consumer interceptor; + protected Consumer> responseInterceptor; + protected Consumer> asyncResponseInterceptor; + protected Duration readTimeout; + protected Duration connectTimeout; + + public static String valueToString(Object value) { + if (value == null) { + return ""; + } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + return value.toString(); + } + + /** + * URL encode a string in the UTF-8 encoding. + * + * @param s String to encode. + * @return URL-encoded representation of the input string. + */ + public static String urlEncode(String s) { + return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20"); + } + + /** + * Convert a URL query name/value parameter to a list of encoded {@link Pair} + * objects. + * + *

The value can be null, in which case an empty list is returned.

+ * + * @param name The query name parameter. + * @param value The query value, which may not be a collection but may be + * null. + * @return A singleton list of the {@link Pair} objects representing the input + * parameters, which is encoded for use in a URL. If the value is null, an + * empty list is returned. + */ + public static List parameterToPairs(String name, Object value) { + if (name == null || name.isEmpty() || value == null) { + return Collections.emptyList(); + } + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); + } + + /** + * Convert a URL query name/collection parameter to a list of encoded + * {@link Pair} objects. + * + * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). + * @param name The query name parameter. + * @param values A collection of values for the given query name, which may be + * null. + * @return A list of {@link Pair} objects representing the input parameters, + * which is encoded for use in a URL. If the values collection is null, an + * empty list is returned. + */ + public static List parameterToPairs( + String collectionFormat, String name, Collection values) { + if (name == null || name.isEmpty() || values == null || values.isEmpty()) { + return Collections.emptyList(); + } + + // get the collection format (default: csv) + String format = collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; + + // create the params based on the collection format + if ("multi".equals(format)) { + return values.stream() + .map(value -> new Pair(urlEncode(name), urlEncode(valueToString(value)))) + .collect(Collectors.toList()); + } + + String delimiter; + switch(format) { + case "csv": + delimiter = urlEncode(","); + break; + case "ssv": + delimiter = urlEncode(" "); + break; + case "tsv": + delimiter = urlEncode("\t"); + break; + case "pipes": + delimiter = urlEncode("|"); + break; + default: + throw new IllegalArgumentException("Illegal collection format: " + collectionFormat); + } + + StringJoiner joiner = new StringJoiner(delimiter); + for (Object value : values) { + joiner.add(urlEncode(valueToString(value))); + } + + return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); + } + + /** + * Create an instance of ApiClient. + */ + public ApiClient() { + this.builder = createDefaultHttpClientBuilder(); + this.mapper = createDefaultObjectMapper(); + updateBaseUri(getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + /** + * Create an instance of ApiClient. + * + * @param builder Http client builder. + * @param mapper Object mapper. + * @param baseUri Base URI + */ + public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri) { + this.builder = builder; + this.mapper = mapper; + updateBaseUri(baseUri != null ? baseUri : getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + public static ObjectMapper createDefaultObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); + return mapper; + } + + protected String getDefaultBaseUri() { + return "http://petstore.swagger.io/v2"; + } + + public static HttpClient.Builder createDefaultHttpClientBuilder() { + return HttpClient.newBuilder(); + } + + public final void updateBaseUri(String baseUri) { + URI uri = URI.create(baseUri); + scheme = uri.getScheme(); + host = uri.getHost(); + port = uri.getPort(); + basePath = uri.getRawPath(); + } + + /** + * Set a custom {@link HttpClient.Builder} object to use when creating the + * {@link HttpClient} that is used by the API client. + * + * @param builder Custom client builder. + * @return This object. + */ + public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { + this.builder = builder; + return this; + } + + /** + * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. + * + *

The returned object is immutable and thread-safe.

+ * + * @return The HTTP client. + */ + public HttpClient getHttpClient() { + return builder.build(); + } + + /** + * Set a custom {@link ObjectMapper} to serialize and deserialize the request + * and response bodies. + * + * @param mapper Custom object mapper. + * @return This object. + */ + public ApiClient setObjectMapper(ObjectMapper mapper) { + this.mapper = mapper; + return this; + } + + /** + * Get a copy of the current {@link ObjectMapper}. + * + * @return A copy of the current object mapper. + */ + public ObjectMapper getObjectMapper() { + return mapper.copy(); + } + + /** + * Set a custom host name for the target service. + * + * @param host The host name of the target service. + * @return This object. + */ + public ApiClient setHost(String host) { + this.host = host; + return this; + } + + /** + * Set a custom port number for the target service. + * + * @param port The port of the target service. Set this to -1 to reset the + * value to the default for the scheme. + * @return This object. + */ + public ApiClient setPort(int port) { + this.port = port; + return this; + } + + /** + * Set a custom base path for the target service, for example '/v2'. + * + * @param basePath The base path against which the rest of the path is + * resolved. + * @return This object. + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get the base URI to resolve the endpoint paths against. + * + * @return The complete base URI that the rest of the API parameters are + * resolved against. + */ + public String getBaseUri() { + return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath; + } + + /** + * Set a custom scheme for the target service, for example 'https'. + * + * @param scheme The scheme of the target service + * @return This object. + */ + public ApiClient setScheme(String scheme){ + this.scheme = scheme; + return this; + } + + /** + * Set a custom request interceptor. + * + *

A request interceptor is a mechanism for altering each request before it + * is sent. After the request has been fully configured but not yet built, the + * request builder is passed into this function for further modification, + * after which it is sent out.

+ * + *

This is useful for altering the requests in a custom manner, such as + * adding headers. It could also be used for logging and monitoring.

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setRequestInterceptor(Consumer interceptor) { + this.interceptor = interceptor; + return this; + } + + /** + * Get the custom interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer getRequestInterceptor() { + return interceptor; + } + + /** + * Set a custom response interceptor. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setResponseInterceptor(Consumer> interceptor) { + this.responseInterceptor = interceptor; + return this; + } + + /** + * Get the custom response interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getResponseInterceptor() { + return responseInterceptor; + } + + /** + * Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { + this.asyncResponseInterceptor = interceptor; + return this; + } + + /** + * Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getAsyncResponseInterceptor() { + return asyncResponseInterceptor; + } + + /** + * Set the read timeout for the http client. + * + *

This is the value used by default for each request, though it can be + * overridden on a per-request basis with a request interceptor.

+ * + * @param readTimeout The read timeout used by default by the http client. + * Setting this value to null resets the timeout to an + * effectively infinite value. + * @return This object. + */ + public ApiClient setReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; + } + + /** + * Get the read timeout that was set. + * + * @return The read timeout, or null if no timeout was set. Null represents + * an infinite wait time. + */ + public Duration getReadTimeout() { + return readTimeout; + } + /** + * Sets the connect timeout (in milliseconds) for the http client. + * + *

In the case where a new connection needs to be established, if + * the connection cannot be established within the given {@code + * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler) + * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or + * {@link HttpClient#sendAsync(HttpRequest,BodyHandler) + * HttpClient::sendAsync} completes exceptionally with an + * {@code HttpConnectTimeoutException}. If a new connection does not + * need to be established, for example if a connection can be reused + * from a previous request, then this timeout duration has no effect. + * + * @param connectTimeout connection timeout in milliseconds + * + * @return This object. + */ + public ApiClient setConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + this.builder.connectTimeout(connectTimeout); + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public Duration getConnectTimeout() { + return connectTimeout; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiException.java new file mode 100644 index 000000000000..40cf030871e8 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiException.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.net.http.HttpHeaders; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + + private int code = 0; + private HttpHeaders responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return Headers as an HttpHeaders object + */ + public HttpHeaders getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiResponse.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiResponse.java new file mode 100644 index 000000000000..4fe1c50cb640 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ApiResponse.java @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/Configuration.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/Configuration.java new file mode 100644 index 000000000000..0cae581b9224 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/Configuration.java @@ -0,0 +1,63 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Configuration { + public static final String VERSION = "1.0.0"; + + private static final AtomicReference defaultApiClient = new AtomicReference<>(); + private static volatile Supplier apiClientFactory = ApiClient::new; + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + ApiClient client = defaultApiClient.get(); + if (client == null) { + client = defaultApiClient.updateAndGet(val -> { + if (val != null) { // changed by another thread + return val; + } + return apiClientFactory.get(); + }); + } + return client; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient.set(apiClient); + } + + /** + * set the callback used to create new ApiClient objects + */ + public static void setApiClientFactory(Supplier factory) { + apiClientFactory = Objects.requireNonNull(factory); + } + + private Configuration() { + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/JSON.java new file mode 100644 index 000000000000..a31feec3de37 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/JSON.java @@ -0,0 +1,264 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import org.openapitools.jackson.nullable.JsonNullableModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.client.model.*; + +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = JsonMapper.builder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) + .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) + .defaultDateFormat(new RFC3339DateFormat()) + .addModule(new JavaTimeModule()) + .build(); + JsonNullableModule jnm = new JsonNullableModule(); + mapper.registerModule(jnm); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public ObjectMapper getMapper() { return mapper; } + + /** + * Returns the target model class that should be used to deserialize the input data. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + * + * @return the target model class. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** + * Helper class to register the discriminator mappings. + */ + @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. + * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + * + * @return the target model class. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, + * so it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + * @param visitedClasses The set of classes that have already been visited. + * + * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. + */ + public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map> descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (Class childType : descendants.values()) { + if (isInstanceOf(childType, inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** + * A map of discriminators for all model classes. + */ + private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); + + /** + * A map of oneOf/anyOf descendants for each model class. + */ + private static Map, Map>> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map> descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/Pair.java new file mode 100644 index 000000000000..f68c7c4267ee --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/Pair.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pair { + private final String name; + private final String value; + + public Pair(String name, String value) { + this.name = isValidString(name) ? name : ""; + this.value = isValidString(value) ? value : ""; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private static boolean isValidString(String arg) { + return arg != null; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339DateFormat.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339DateFormat.java new file mode 100644 index 000000000000..bf31c230689b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339DateFormat.java @@ -0,0 +1,58 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.text.DecimalFormat; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse(String source) { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return super.clone(); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 000000000000..bf2c22b0307e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + private static final long serialVersionUID = 1L; + private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault(); + private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + = JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault(); + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false, // keep zero offset and Z separate since zones explicitly supported + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ, + boolean normalizeZoneId, + boolean readNumericStringsAsTimestamp) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ, + normalizeZoneId, + readNumericStringsAsTimestamp + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 000000000000..4a1b4455149c --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + private static final long serialVersionUID = 1L; + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ServerConfiguration.java new file mode 100644 index 000000000000..f8f7463b36bd --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ServerConfiguration.java @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ServerVariable.java new file mode 100644 index 000000000000..d55d94af33d3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/PetApi.java new file mode 100644 index 000000000000..f821c11fe67e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/PetApi.java @@ -0,0 +1,1110 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class PetApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public PetApi() { + this(Configuration.getDefaultApiClient()); + } + + public PetApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPet(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = addPetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPetWithHttpInfo(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("addPet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePet(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + deletePetWithHttpInfo(petId, apiKey, headers); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePetWithHttpInfo(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deletePet", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + if (apiKey != null) { + localVarRequestBuilder.header("api_key", apiKey.toString()); + } + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatus(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatusWithHttpInfo(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByStatus", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByStatus"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "status"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTags(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTagsWithHttpInfo(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByTags", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByTags"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "tags"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetById(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId, headers); + return localVarResponse.getData(); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetByIdWithHttpInfo(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getPetById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePet(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = updatePetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePetWithHttpInfo(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithForm(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + updatePetWithFormWithHttpInfo(petId, name, status, headers); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithFormWithHttpInfo(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePetWithForm", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + List formValues = new ArrayList<>(); + if (name != null) { + formValues.add(new BasicNameValuePair("name", name.toString())); + } + if (status != null) { + formValues.add(new BasicNameValuePair("status", status.toString())); + } + HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8); + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()))); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFile(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file, headers); + return localVarResponse.getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFileWithHttpInfo(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("uploadFile", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}/uploadImage" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create(); + boolean hasFiles = false; + if (additionalMetadata != null) { + multiPartBuilder.addTextBody("additionalMetadata", additionalMetadata.toString()); + } + multiPartBuilder.addBinaryBody("file", _file); + hasFiles = true; + HttpEntity entity = multiPartBuilder.build(); + HttpRequest.BodyPublisher formDataPublisher; + if (hasFiles) { + Pipe pipe; + try { + pipe = Pipe.open(); + } catch (IOException e) { + throw new RuntimeException(e); + } + new Thread(() -> { + try (OutputStream outputStream = Channels.newOutputStream(pipe.sink())) { + entity.writeTo(outputStream); + } catch (IOException e) { + e.printStackTrace(); + } + }).start(); + formDataPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> Channels.newInputStream(pipe.source())); + } else { + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + formDataPublisher = HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray())); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", formDataPublisher); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/StoreApi.java new file mode 100644 index 000000000000..7d7f807eb763 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/StoreApi.java @@ -0,0 +1,535 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import org.openapitools.client.model.Order; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class StoreApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public StoreApi() { + this(Configuration.getDefaultApiClient()); + } + + public StoreApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrder(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + deleteOrderWithHttpInfo(orderId, headers); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrderWithHttpInfo(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteOrder", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory() throws ApiException { + return getInventory(, null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory(Map headers) throws ApiException { + ApiResponse> localVarResponse = getInventoryWithHttpInfo(headers); + return localVarResponse.getData(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { + return getInventoryWithHttpInfo(, null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getInventory", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getInventoryRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/inventory"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderById(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId, headers); + return localVarResponse.getData(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderByIdWithHttpInfo(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getOrderById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrder(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + ApiResponse localVarResponse = placeOrderWithHttpInfo(order, headers); + return localVarResponse.getData(); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrderWithHttpInfo(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("placeOrder", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + // verify the required parameter 'order' is set + if (order == null) { + throw new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(order); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/UserApi.java new file mode 100644 index 000000000000..a47a70c5cdbb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/api/UserApi.java @@ -0,0 +1,995 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class UserApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public UserApi() { + this(Configuration.getDefaultApiClient()); + } + + public UserApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user) throws ApiException { + return createUser(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + createUserWithHttpInfo(user, headers); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user) throws ApiException { + return createUserWithHttpInfo(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithArrayInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithArrayInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithArray"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithListInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithListInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithList"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUser(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + deleteUserWithHttpInfo(username, headers); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUserWithHttpInfo(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByName(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + ApiResponse localVarResponse = getUserByNameWithHttpInfo(username, headers); + return localVarResponse.getData(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByNameWithHttpInfo(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getUserByName", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUser(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + ApiResponse localVarResponse = loginUserWithHttpInfo(username, password, headers); + return localVarResponse.getData(); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUserWithHttpInfo(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("loginUser", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); + } + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/login"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "username"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("username", username)); + localVarQueryParameterBaseName = "password"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("password", password)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs out current logged in user session + * + * @throws ApiException if fails to make API call + */ + public void logoutUser() throws ApiException { + return logoutUser(, null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void logoutUser(Map headers) throws ApiException { + logoutUserWithHttpInfo(headers); + } + + /** + * Logs out current logged in user session + * + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo() throws ApiException { + return logoutUserWithHttpInfo(, null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("logoutUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder logoutUserRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/logout"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUser(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + updateUserWithHttpInfo(username, user, headers); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUserWithHttpInfo(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updateUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); + } + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling updateUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000000..e8067ce57039 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.lang.reflect.Type; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Category.java new file mode 100644 index 000000000000..3fc25d568852 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Category.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A category for a pet + */ +@JsonPropertyOrder({ + Category.JSON_PROPERTY_ID, + Category.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Category { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Category() { + } + + public Category id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Category name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Category object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/ModelApiResponse.java new file mode 100644 index 000000000000..69587939b7ae --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -0,0 +1,223 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * Describes the result of uploading an image resource + */ +@JsonPropertyOrder({ + ModelApiResponse.JSON_PROPERTY_CODE, + ModelApiResponse.JSON_PROPERTY_TYPE, + ModelApiResponse.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ModelApiResponse { + public static final String JSON_PROPERTY_CODE = "code"; + @javax.annotation.Nullable + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + @javax.annotation.Nullable + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + @javax.annotation.Nullable + private String message; + + public ModelApiResponse() { + } + + public ModelApiResponse code(@javax.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(@javax.annotation.Nullable Integer code) { + this.code = code; + } + + + public ModelApiResponse type(@javax.annotation.Nullable String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(@javax.annotation.Nullable String type) { + this.type = type; + } + + + public ModelApiResponse message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + /** + * Return true if this ApiResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format("%scode%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getCode())))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format("%stype%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getType())))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format("%smessage%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getMessage())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Order.java new file mode 100644 index 000000000000..04d9d6ddfe99 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Order.java @@ -0,0 +1,369 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.time.OffsetDateTime; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * An order for a pets from the pet store + */ +@JsonPropertyOrder({ + Order.JSON_PROPERTY_ID, + Order.JSON_PROPERTY_PET_ID, + Order.JSON_PROPERTY_QUANTITY, + Order.JSON_PROPERTY_SHIP_DATE, + Order.JSON_PROPERTY_STATUS, + Order.JSON_PROPERTY_COMPLETE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Order { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_PET_ID = "petId"; + @javax.annotation.Nullable + private Long petId; + + public static final String JSON_PROPERTY_QUANTITY = "quantity"; + @javax.annotation.Nullable + private Integer quantity; + + public static final String JSON_PROPERTY_SHIP_DATE = "shipDate"; + @javax.annotation.Nullable + private OffsetDateTime shipDate; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED(String.valueOf("placed")), + + APPROVED(String.valueOf("approved")), + + DELIVERED(String.valueOf("delivered")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public static final String JSON_PROPERTY_COMPLETE = "complete"; + @javax.annotation.Nullable + private Boolean complete = false; + + public Order() { + } + + public Order id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Order petId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getPetId() { + return petId; + } + + + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPetId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + } + + + public Order quantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getQuantity() { + return quantity; + } + + + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setQuantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + } + + + public Order shipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getShipDate() { + return shipDate; + } + + + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setShipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + } + + + public Order status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + public Order complete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getComplete() { + return complete; + } + + + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComplete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + } + + + /** + * Return true if this Order object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `petId` to the URL query string + if (getPetId() != null) { + joiner.add(String.format("%spetId%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPetId())))); + } + + // add `quantity` to the URL query string + if (getQuantity() != null) { + joiner.add(String.format("%squantity%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getQuantity())))); + } + + // add `shipDate` to the URL query string + if (getShipDate() != null) { + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getShipDate())))); + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + // add `complete` to the URL query string + if (getComplete() != null) { + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getComplete())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Pet.java new file mode 100644 index 000000000000..279392c70ca1 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Pet.java @@ -0,0 +1,397 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A pet for sale in the pet store + */ +@JsonPropertyOrder({ + Pet.JSON_PROPERTY_ID, + Pet.JSON_PROPERTY_CATEGORY, + Pet.JSON_PROPERTY_NAME, + Pet.JSON_PROPERTY_PHOTO_URLS, + Pet.JSON_PROPERTY_TAGS, + Pet.JSON_PROPERTY_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pet { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_CATEGORY = "category"; + @javax.annotation.Nullable + private Category category; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nonnull + private String name; + + public static final String JSON_PROPERTY_PHOTO_URLS = "photoUrls"; + @javax.annotation.Nonnull + private List photoUrls = new ArrayList<>(); + + public static final String JSON_PROPERTY_TAGS = "tags"; + @javax.annotation.Nullable + private List tags = new ArrayList<>(); + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE(String.valueOf("available")), + + PENDING(String.valueOf("pending")), + + SOLD(String.valueOf("sold")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public Pet() { + } + + public Pet id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Pet category(@javax.annotation.Nullable Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Category getCategory() { + return category; + } + + + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCategory(@javax.annotation.Nullable Category category) { + this.category = category; + } + + + public Pet name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public Pet photoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + if (this.photoUrls == null) { + this.photoUrls = new ArrayList<>(); + } + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getPhotoUrls() { + return photoUrls; + } + + + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setPhotoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + } + + + public Pet tags(@javax.annotation.Nullable List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTags() { + return tags; + } + + + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTags(@javax.annotation.Nullable List tags) { + this.tags = tags; + } + + + public Pet status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + /** + * Return true if this Pet object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `category` to the URL query string + if (getCategory() != null) { + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + // add `photoUrls` to the URL query string + if (getPhotoUrls() != null) { + for (int i = 0; i < getPhotoUrls().size(); i++) { + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + ApiClient.urlEncode(ApiClient.valueToString(getPhotoUrls().get(i))))); + } + } + + // add `tags` to the URL query string + if (getTags() != null) { + for (int i = 0; i < getTags().size(); i++) { + if (getTags().get(i) != null) { + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Tag.java new file mode 100644 index 000000000000..990e6df14174 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/Tag.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A tag for a pet + */ +@JsonPropertyOrder({ + Tag.JSON_PROPERTY_ID, + Tag.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Tag { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Tag() { + } + + public Tag id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Tag name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Tag object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/User.java new file mode 100644 index 000000000000..5c1220725114 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/main/java/org/openapitools/client/model/User.java @@ -0,0 +1,403 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A User who is purchasing from the pet store + */ +@JsonPropertyOrder({ + User.JSON_PROPERTY_ID, + User.JSON_PROPERTY_USERNAME, + User.JSON_PROPERTY_FIRST_NAME, + User.JSON_PROPERTY_LAST_NAME, + User.JSON_PROPERTY_EMAIL, + User.JSON_PROPERTY_PASSWORD, + User.JSON_PROPERTY_PHONE, + User.JSON_PROPERTY_USER_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:08:28.986952+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class User { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_USERNAME = "username"; + @javax.annotation.Nullable + private String username; + + public static final String JSON_PROPERTY_FIRST_NAME = "firstName"; + @javax.annotation.Nullable + private String firstName; + + public static final String JSON_PROPERTY_LAST_NAME = "lastName"; + @javax.annotation.Nullable + private String lastName; + + public static final String JSON_PROPERTY_EMAIL = "email"; + @javax.annotation.Nullable + private String email; + + public static final String JSON_PROPERTY_PASSWORD = "password"; + @javax.annotation.Nullable + private String password; + + public static final String JSON_PROPERTY_PHONE = "phone"; + @javax.annotation.Nullable + private String phone; + + public static final String JSON_PROPERTY_USER_STATUS = "userStatus"; + @javax.annotation.Nullable + private Integer userStatus; + + public User() { + } + + public User id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public User username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUsername() { + return username; + } + + + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + + public User firstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstName() { + return firstName; + } + + + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + } + + + public User lastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLastName() { + return lastName; + } + + + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + } + + + public User email(@javax.annotation.Nullable String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEmail() { + return email; + } + + + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEmail(@javax.annotation.Nullable String email) { + this.email = email; + } + + + public User password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPassword() { + return password; + } + + + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + + public User phone(@javax.annotation.Nullable String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPhone() { + return phone; + } + + + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPhone(@javax.annotation.Nullable String phone) { + this.phone = phone; + } + + + public User userStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getUserStatus() { + return userStatus; + } + + + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUserStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + } + + + /** + * Return true if this User object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `username` to the URL query string + if (getUsername() != null) { + joiner.add(String.format("%susername%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUsername())))); + } + + // add `firstName` to the URL query string + if (getFirstName() != null) { + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getFirstName())))); + } + + // add `lastName` to the URL query string + if (getLastName() != null) { + joiner.add(String.format("%slastName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getLastName())))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add(String.format("%semail%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getEmail())))); + } + + // add `password` to the URL query string + if (getPassword() != null) { + joiner.add(String.format("%spassword%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPassword())))); + } + + // add `phone` to the URL query string + if (getPhone() != null) { + joiner.add(String.format("%sphone%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPhone())))); + } + + // add `userStatus` to the URL query string + if (getUserStatus() != null) { + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUserStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/PetApiTest.java new file mode 100644 index 000000000000..f725ba246938 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -0,0 +1,180 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for PetApi + */ +@Disabled +public class PetApiTest { + + private final PetApi api = new PetApi(); + + + /** + * Add a new pet to the store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void addPetTest() throws ApiException { + Pet pet = null; + Pet response = + api.addPet(pet); + + // TODO: test validations + } + + /** + * Deletes a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deletePetTest() throws ApiException { + Long petId = null; + String apiKey = null; + + api.deletePet(petId, apiKey); + + // TODO: test validations + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByStatusTest() throws ApiException { + List status = null; + List response = + api.findPetsByStatus(status); + + // TODO: test validations + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByTagsTest() throws ApiException { + List tags = null; + List response = + api.findPetsByTags(tags); + + // TODO: test validations + } + + /** + * Find pet by ID + * + * Returns a single pet + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getPetByIdTest() throws ApiException { + Long petId = null; + Pet response = + api.getPetById(petId); + + // TODO: test validations + } + + /** + * Update an existing pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetTest() throws ApiException { + Pet pet = null; + Pet response = + api.updatePet(pet); + + // TODO: test validations + } + + /** + * Updates a pet in the store with form data + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetWithFormTest() throws ApiException { + Long petId = null; + String name = null; + String status = null; + + api.updatePetWithForm(petId, name, status); + + // TODO: test validations + } + + /** + * uploads an image + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileTest() throws ApiException { + Long petId = null; + String additionalMetadata = null; + File _file = null; + ModelApiResponse response = + api.uploadFile(petId, additionalMetadata, _file); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/StoreApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/StoreApiTest.java new file mode 100644 index 000000000000..be318cab8b1e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/StoreApiTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import org.openapitools.client.model.Order; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for StoreApi + */ +@Disabled +public class StoreApiTest { + + private final StoreApi api = new StoreApi(); + + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteOrderTest() throws ApiException { + String orderId = null; + + api.deleteOrder(orderId); + + // TODO: test validations + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getInventoryTest() throws ApiException { + Map response = + api.getInventory(); + + // TODO: test validations + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getOrderByIdTest() throws ApiException { + Long orderId = null; + Order response = + api.getOrderById(orderId); + + // TODO: test validations + } + + /** + * Place an order for a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void placeOrderTest() throws ApiException { + Order order = null; + Order response = + api.placeOrder(order); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/UserApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/UserApiTest.java new file mode 100644 index 000000000000..2b2b7a60fd21 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/api/UserApiTest.java @@ -0,0 +1,175 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for UserApi + */ +@Disabled +public class UserApiTest { + + private final UserApi api = new UserApi(); + + + /** + * Create user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUserTest() throws ApiException { + User user = null; + + api.createUser(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() throws ApiException { + List user = null; + + api.createUsersWithArrayInput(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() throws ApiException { + List user = null; + + api.createUsersWithListInput(user); + + // TODO: test validations + } + + /** + * Delete user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteUserTest() throws ApiException { + String username = null; + + api.deleteUser(username); + + // TODO: test validations + } + + /** + * Get user by user name + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserByNameTest() throws ApiException { + String username = null; + User response = + api.getUserByName(username); + + // TODO: test validations + } + + /** + * Logs user into the system + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void loginUserTest() throws ApiException { + String username = null; + String password = null; + String response = + api.loginUser(username, password); + + // TODO: test validations + } + + /** + * Logs out current logged in user session + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void logoutUserTest() throws ApiException { + + api.logoutUser(); + + // TODO: test validations + } + + /** + * Updated user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserTest() throws ApiException { + String username = null; + User user = null; + + api.updateUser(username, user); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/CategoryTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/CategoryTest.java new file mode 100644 index 000000000000..ae23ab433a50 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/CategoryTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Category + */ +class CategoryTest { + private final Category model = new Category(); + + /** + * Model tests for Category + */ + @Test + void testCategory() { + // TODO: test Category + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java new file mode 100644 index 000000000000..c846563bfe1f --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java @@ -0,0 +1,64 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ModelApiResponse + */ +class ModelApiResponseTest { + private final ModelApiResponse model = new ModelApiResponse(); + + /** + * Model tests for ModelApiResponse + */ + @Test + void testModelApiResponse() { + // TODO: test ModelApiResponse + } + + /** + * Test the property 'code' + */ + @Test + void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + void messageTest() { + // TODO: test message + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/OrderTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/OrderTest.java new file mode 100644 index 000000000000..4d8d136809eb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/OrderTest.java @@ -0,0 +1,89 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Order + */ +class OrderTest { + private final Order model = new Order(); + + /** + * Model tests for Order + */ + @Test + void testOrder() { + // TODO: test Order + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'petId' + */ + @Test + void petIdTest() { + // TODO: test petId + } + + /** + * Test the property 'quantity' + */ + @Test + void quantityTest() { + // TODO: test quantity + } + + /** + * Test the property 'shipDate' + */ + @Test + void shipDateTest() { + // TODO: test shipDate + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + + /** + * Test the property 'complete' + */ + @Test + void completeTest() { + // TODO: test complete + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/PetTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/PetTest.java new file mode 100644 index 000000000000..84aff8adbf96 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/PetTest.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Pet + */ +class PetTest { + private final Pet model = new Pet(); + + /** + * Model tests for Pet + */ + @Test + void testPet() { + // TODO: test Pet + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'category' + */ + @Test + void categoryTest() { + // TODO: test category + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'photoUrls' + */ + @Test + void photoUrlsTest() { + // TODO: test photoUrls + } + + /** + * Test the property 'tags' + */ + @Test + void tagsTest() { + // TODO: test tags + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/TagTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/TagTest.java new file mode 100644 index 000000000000..6bd8b9f5035e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/TagTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Tag + */ +class TagTest { + private final Tag model = new Tag(); + + /** + * Model tests for Tag + */ + @Test + void testTag() { + // TODO: test Tag + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/UserTest.java b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/UserTest.java new file mode 100644 index 000000000000..40f4892264aa --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed2/src/test/java/org/openapitools/client/model/UserTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for User + */ +class UserTest { + private final User model = new User(); + + /** + * Model tests for User + */ + @Test + void testUser() { + // TODO: test User + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'username' + */ + @Test + void usernameTest() { + // TODO: test username + } + + /** + * Test the property 'firstName' + */ + @Test + void firstNameTest() { + // TODO: test firstName + } + + /** + * Test the property 'lastName' + */ + @Test + void lastNameTest() { + // TODO: test lastName + } + + /** + * Test the property 'email' + */ + @Test + void emailTest() { + // TODO: test email + } + + /** + * Test the property 'password' + */ + @Test + void passwordTest() { + // TODO: test password + } + + /** + * Test the property 'phone' + */ + @Test + void phoneTest() { + // TODO: test phone + } + + /** + * Test the property 'userStatus' + */ + @Test + void userStatusTest() { + // TODO: test userStatus + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/.github/workflows/maven.yml b/samples/client/petstore/java/native/test-regenerated-fixed3/.github/workflows/maven.yml new file mode 100644 index 000000000000..460f78bfd1b2 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/.github/workflows/maven.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build OpenAPI Petstore + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 17, 21 ] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/.gitignore b/samples/client/petstore/java/native/test-regenerated-fixed3/.gitignore new file mode 100644 index 000000000000..a530464afa1b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/.gitignore @@ -0,0 +1,21 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator-ignore b/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator/FILES b/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator/FILES new file mode 100644 index 000000000000..57d506c4c50b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator/FILES @@ -0,0 +1,56 @@ +.github/workflows/maven.yml +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +build.gradle +build.sbt +docs/Category.md +docs/ModelApiResponse.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +git_push.sh +gradle.properties +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/AndroidManifest.xml +src/main/java/org/openapitools/client/ApiClient.java +src/main/java/org/openapitools/client/ApiException.java +src/main/java/org/openapitools/client/ApiResponse.java +src/main/java/org/openapitools/client/Configuration.java +src/main/java/org/openapitools/client/JSON.java +src/main/java/org/openapitools/client/Pair.java +src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java +src/main/java/org/openapitools/client/ServerConfiguration.java +src/main/java/org/openapitools/client/ServerVariable.java +src/main/java/org/openapitools/client/api/PetApi.java +src/main/java/org/openapitools/client/api/StoreApi.java +src/main/java/org/openapitools/client/api/UserApi.java +src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java +src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ModelApiResponse.java +src/main/java/org/openapitools/client/model/Order.java +src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Tag.java +src/main/java/org/openapitools/client/model/User.java +src/test/java/org/openapitools/client/api/PetApiTest.java +src/test/java/org/openapitools/client/api/StoreApiTest.java +src/test/java/org/openapitools/client/api/UserApiTest.java +src/test/java/org/openapitools/client/model/CategoryTest.java +src/test/java/org/openapitools/client/model/ModelApiResponseTest.java +src/test/java/org/openapitools/client/model/OrderTest.java +src/test/java/org/openapitools/client/model/PetTest.java +src/test/java/org/openapitools/client/model/TagTest.java +src/test/java/org/openapitools/client/model/UserTest.java diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator/VERSION b/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator/VERSION new file mode 100644 index 000000000000..fc74d6ceba8e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.15.0-SNAPSHOT diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/.travis.yml b/samples/client/petstore/java/native/test-regenerated-fixed3/.travis.yml new file mode 100644 index 000000000000..c94647479234 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/.travis.yml @@ -0,0 +1,16 @@ +# +# Generated by: https://openapi-generator.tech +# +language: java +jdk: + - oraclejdk11 +before_install: + # ensure gradlew has proper permission + - chmod a+x ./gradlew +script: + # test using maven + - mvn test + # uncomment below to test using gradle + # - gradle test + # uncomment below to test using sbt + # - sbt test diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/README.md b/samples/client/petstore/java/native/test-regenerated-fixed3/README.md new file mode 100644 index 000000000000..7da3e246f9b3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/README.md @@ -0,0 +1,197 @@ +# openapi-java-client + +OpenAPI Petstore + +- API version: 1.0.0 + +- Build date: 2025-07-08T21:09:56.830832+07:00[Asia/Bangkok] + +- Generator version: 7.15.0-SNAPSHOT + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + +## Requirements + +Building the API client library requires: + +1. Java 11+ +2. Maven/Gradle + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn clean deploy +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + org.openapitools + openapi-java-client + 1.0.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "org.openapitools:openapi-java-client:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +- `target/openapi-java-client-1.0.0.jar` +- `target/lib/*.jar` + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import org.openapitools.client.*; +import org.openapitools.client.model.*; +import org.openapitools.client.api.PetApi; + +public class PetApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + // Configure clients using the `defaultClient` object, such as + // overriding the host and port, timeout, etc. + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetWithHttpInfo**](docs/PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**deletePetWithHttpInfo**](docs/PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByStatusWithHttpInfo**](docs/PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**findPetsByTagsWithHttpInfo**](docs/PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**getPetByIdWithHttpInfo**](docs/PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithHttpInfo**](docs/PetApi.md#updatePetWithHttpInfo) | **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* | [**updatePetWithFormWithHttpInfo**](docs/PetApi.md#updatePetWithFormWithHttpInfo) | **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* | [**uploadFileWithHttpInfo**](docs/PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**deleteOrderWithHttpInfo**](docs/StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryWithHttpInfo**](docs/StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**getOrderByIdWithHttpInfo**](docs/StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*StoreApi* | [**placeOrderWithHttpInfo**](docs/StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUserWithHttpInfo**](docs/UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithArrayInputWithHttpInfo**](docs/UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**createUsersWithListInputWithHttpInfo**](docs/UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**deleteUserWithHttpInfo**](docs/UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**getUserByNameWithHttpInfo**](docs/UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**loginUserWithHttpInfo**](docs/UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**logoutUserWithHttpInfo**](docs/UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user +*UserApi* | [**updateUserWithHttpInfo**](docs/UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Category](docs/Category.md) + - [ModelApiResponse](docs/ModelApiResponse.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### petstore_auth + + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + + +### api_key + + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. +However, the instances of the api clients created from the `ApiClient` are thread-safe and can be re-used. + +## Author + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/api/openapi.yaml b/samples/client/petstore/java/native/test-regenerated-fixed3/api/openapi.yaml new file mode 100644 index 000000000000..9b1b54b9454b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/api/openapi.yaml @@ -0,0 +1,865 @@ +openapi: 3.0.0 +info: + description: "This is a sample server Petstore server. For this sample, you can\ + \ use the api key `special-key` to test the authorization filters." + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://petstore.swagger.io/v2 +tags: +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user +paths: + /pet: + post: + description: "" + operationId: addPet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + put: + description: "" + operationId: updatePet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + "405": + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /pet/findByStatus: + get: + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - description: Status values that need to be considered for filter + explode: false + in: query + name: status + required: true + schema: + items: + default: available + enum: + - available + - pending + - sold + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid status value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by status + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/findByTags: + get: + deprecated: true + description: "Multiple tags can be provided with comma separated strings. Use\ + \ tag1, tag2, tag3 for testing." + operationId: findPetsByTags + parameters: + - description: Tags to filter by + explode: false + in: query + name: tags + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid tag value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/{petId}: + delete: + description: "" + operationId: deletePet + parameters: + - explode: false + in: header + name: api_key + required: false + schema: + type: string + style: simple + - description: Pet id to delete + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "400": + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet + tags: + - pet + x-accepts: + - application/json + get: + description: Returns a single pet + operationId: getPetById + parameters: + - description: ID of pet to return + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: + - application/json + - application/xml + post: + description: "" + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/updatePetWithForm_request" + responses: + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-content-type: application/x-www-form-urlencoded + x-accepts: + - application/json + /pet/{petId}/uploadImage: + post: + description: "" + operationId: uploadFile + 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/uploadFile_request" + 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 + x-content-type: multipart/form-data + x-accepts: + - application/json + /store/inventory: + get: + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + "200": + content: + application/json: + schema: + additionalProperties: + format: int32 + type: integer + type: object + description: successful operation + security: + - api_key: [] + summary: Returns pet inventories by status + tags: + - store + x-accepts: + - application/json + /store/order: + post: + description: "" + operationId: placeOrder + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Order" + description: order placed for purchasing the pet + required: true + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /store/order/{orderId}: + delete: + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - description: ID of the order that needs to be deleted + explode: false + in: path + name: orderId + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Delete purchase order by ID + tags: + - store + x-accepts: + - application/json + get: + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generate exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + explode: false + in: path + name: orderId + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Find purchase order by ID + tags: + - store + x-accepts: + - application/json + - application/xml + /user: + post: + description: This can only be done by the logged in user. + operationId: createUser + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Created user object + required: true + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Create user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithArray: + post: + description: "" + operationId: createUsersWithArrayInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithList: + post: + description: "" + operationId: createUsersWithListInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/login: + get: + description: "" + operationId: loginUser + parameters: + - description: The user name for login + explode: true + in: query + name: username + required: true + schema: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + style: form + - description: The password for login in clear text + explode: true + in: query + name: password + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + Set-Cookie: + description: Cookie authentication key for use with the `api_key` apiKey + authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple + X-Rate-Limit: + description: calls per hour allowed by the user + explode: false + schema: + format: int32 + type: integer + style: simple + X-Expires-After: + description: date in UTC when token expires + explode: false + schema: + format: date-time + type: string + style: simple + "400": + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: + - application/json + - application/xml + /user/logout: + get: + description: "" + operationId: logoutUser + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Logs out current logged in user session + tags: + - user + x-accepts: + - application/json + /user/{username}: + delete: + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - description: The name that needs to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid username supplied + "404": + description: User not found + security: + - api_key: [] + summary: Delete user + tags: + - user + x-accepts: + - application/json + get: + description: "" + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/User" + application/json: + schema: + $ref: "#/components/schemas/User" + description: successful operation + "400": + description: Invalid username supplied + "404": + description: User not found + summary: Get user by user name + tags: + - user + x-accepts: + - application/json + - application/xml + put: + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - description: name that need to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Updated user object + required: true + responses: + "400": + description: Invalid user supplied + "404": + description: User not found + security: + - api_key: [] + summary: Updated user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json +components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: "#/components/schemas/User" + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + application/xml: + schema: + $ref: "#/components/schemas/Pet" + description: Pet object that needs to be added to the store + required: true + schemas: + ApiResponse: + description: Describes the result of uploading an image resource + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + title: An uploaded response + type: object + Pet: + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + category: + $ref: "#/components/schemas/Category" + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: "#/components/schemas/Tag" + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + title: a Pet + type: object + xml: + name: Pet + Order: + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + title: Pet Order + type: object + xml: + name: Order + User: + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + description: User Status + format: int32 + type: integer + title: a User + type: object + xml: + name: User + Category: + description: A category for a pet + example: + name: name + id: 6 + properties: + id: + format: int64 + type: integer + name: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + title: Pet category + type: object + xml: + name: Category + Tag: + description: A tag for a pet + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + title: Pet Tag + type: object + xml: + name: Tag + updatePetWithForm_request: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + uploadFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object + securitySchemes: + petstore_auth: + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + type: oauth2 + api_key: + in: header + name: api_key + type: apiKey + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/build.gradle b/samples/client/petstore/java/native/test-regenerated-fixed3/build.gradle new file mode 100644 index 000000000000..56fa470fb767 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/build.gradle @@ -0,0 +1,109 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'com.diffplug.spotless' + +group = 'org.openapitools' +version = '1.0.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} + +apply plugin: 'java' +apply plugin: 'maven-publish' + +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 + +// Some text from the schema is copy pasted into the source files as UTF-8 +// but the default still seems to be to use platform encoding +tasks.withType(JavaCompile) { + configure(options) { + options.encoding = 'UTF-8' + } +} +javadoc { + options.encoding = 'UTF-8' +} + +publishing { + publications { + maven(MavenPublication) { + artifactId = 'openapi-java-client' + from components.java + } + } +} + +task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath +} + +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + + +ext { + jackson_version = "2.17.1" + jakarta_annotation_version = "1.3.5" + beanvalidation_version = "2.0.2" + junit_version = "5.10.2" + httpmime_version = "4.5.13" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" + implementation "org.openapitools:jackson-databind-nullable:0.2.1" + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + implementation "org.apache.httpcomponents:httpmime:$httpmime_version" + testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + removeUnusedImports() + importOrder() + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/build.sbt b/samples/client/petstore/java/native/test-regenerated-fixed3/build.sbt new file mode 100644 index 000000000000..464090415c47 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/build.sbt @@ -0,0 +1 @@ +# TODO diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Category.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Category.md new file mode 100644 index 000000000000..a7fc939d252e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Category.md @@ -0,0 +1,15 @@ + + +# Category + +A category for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/ModelApiResponse.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/ModelApiResponse.md new file mode 100644 index 000000000000..cd7e3c400be6 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/ModelApiResponse.md @@ -0,0 +1,16 @@ + + +# ModelApiResponse + +Describes the result of uploading an image resource + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Order.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Order.md new file mode 100644 index 000000000000..0c33059b8b6a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Order.md @@ -0,0 +1,29 @@ + + +# Order + +An order for a pets from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**petId** | **Long** | | [optional] | +|**quantity** | **Integer** | | [optional] | +|**shipDate** | **OffsetDateTime** | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] | +|**complete** | **Boolean** | | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| PLACED | "placed" | +| APPROVED | "approved" | +| DELIVERED | "delivered" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Pet.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Pet.md new file mode 100644 index 000000000000..8bb363301232 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Pet.md @@ -0,0 +1,29 @@ + + +# Pet + +A pet for sale in the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**category** | [**Category**](Category.md) | | [optional] | +|**name** | **String** | | | +|**photoUrls** | **List<String>** | | | +|**tags** | [**List<Tag>**](Tag.md) | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| AVAILABLE | "available" | +| PENDING | "pending" | +| SOLD | "sold" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/PetApi.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/PetApi.md new file mode 100644 index 000000000000..51f089e85389 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/PetApi.md @@ -0,0 +1,1212 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store | +| [**addPetWithHttpInfo**](PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store | +| [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet | +| [**deletePetWithHttpInfo**](PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet | +| [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByStatusWithHttpInfo**](PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags | +| [**findPetsByTagsWithHttpInfo**](PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags | +| [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID | +| [**getPetByIdWithHttpInfo**](PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID | +| [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet | +| [**updatePetWithHttpInfo**](PetApi.md#updatePetWithHttpInfo) | **PUT** /pet | Update an existing pet | +| [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**updatePetWithFormWithHttpInfo**](PetApi.md#updatePetWithFormWithHttpInfo) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image | +| [**uploadFileWithHttpInfo**](PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image | + + + +## addPet + +> Pet addPet(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + +## addPetWithHttpInfo + +> ApiResponse addPet addPetWithHttpInfo(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.addPetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + + +## deletePet + +> void deletePet(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + apiInstance.deletePet(petId, apiKey); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + +## deletePetWithHttpInfo + +> ApiResponse deletePet deletePetWithHttpInfo(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + ApiResponse response = apiInstance.deletePetWithHttpInfo(petId, apiKey); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + + +## findPetsByStatus + +> List findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + List result = apiInstance.findPetsByStatus(status); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + +## findPetsByStatusWithHttpInfo + +> ApiResponse> findPetsByStatus findPetsByStatusWithHttpInfo(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + ApiResponse> response = apiInstance.findPetsByStatusWithHttpInfo(status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + + +## findPetsByTags + +> List findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + List result = apiInstance.findPetsByTags(tags); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + +## findPetsByTagsWithHttpInfo + +> ApiResponse> findPetsByTags findPetsByTagsWithHttpInfo(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + ApiResponse> response = apiInstance.findPetsByTagsWithHttpInfo(tags); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + + +## getPetById + +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + Pet result = apiInstance.getPetById(petId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +## getPetByIdWithHttpInfo + +> ApiResponse getPetById getPetByIdWithHttpInfo(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + ApiResponse response = apiInstance.getPetByIdWithHttpInfo(petId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + + +## updatePet + +> Pet updatePet(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.updatePet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + +## updatePetWithHttpInfo + +> ApiResponse updatePet updatePetWithHttpInfo(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.updatePetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + + +## updatePetWithForm + +> void updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + apiInstance.updatePetWithForm(petId, name, status); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +## updatePetWithFormWithHttpInfo + +> ApiResponse updatePetWithForm updatePetWithFormWithHttpInfo(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + ApiResponse response = apiInstance.updatePetWithFormWithHttpInfo(petId, name, status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + + +## uploadFile + +> ModelApiResponse uploadFile(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, _file); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +[**ModelApiResponse**](ModelApiResponse.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 | - | + +## uploadFileWithHttpInfo + +> ApiResponse uploadFile uploadFileWithHttpInfo(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ApiResponse response = apiInstance.uploadFileWithHttpInfo(petId, additionalMetadata, _file); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +ApiResponse<[**ModelApiResponse**](ModelApiResponse.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 | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/StoreApi.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/StoreApi.md new file mode 100644 index 000000000000..7dfbbe315c11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/StoreApi.md @@ -0,0 +1,564 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**deleteOrderWithHttpInfo**](StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status | +| [**getInventoryWithHttpInfo**](StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status | +| [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**getOrderByIdWithHttpInfo**](StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet | +| [**placeOrderWithHttpInfo**](StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet | + + + +## deleteOrder + +> void deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + apiInstance.deleteOrder(orderId); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## deleteOrderWithHttpInfo + +> ApiResponse deleteOrder deleteOrderWithHttpInfo(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + ApiResponse response = apiInstance.deleteOrderWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## getInventory + +> Map getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + Map result = apiInstance.getInventory(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**Map<String, Integer>** + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +## getInventoryWithHttpInfo + +> ApiResponse> getInventory getInventoryWithHttpInfo() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + ApiResponse> response = apiInstance.getInventoryWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +ApiResponse<**Map<String, Integer>**> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + +## getOrderById + +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + Order result = apiInstance.getOrderById(orderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## getOrderByIdWithHttpInfo + +> ApiResponse getOrderById getOrderByIdWithHttpInfo(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + ApiResponse response = apiInstance.getOrderByIdWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## placeOrder + +> Order placeOrder(order) + +Place an order for a pet + + + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + Order result = apiInstance.placeOrder(order); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + +## placeOrderWithHttpInfo + +> ApiResponse placeOrder placeOrderWithHttpInfo(order) + +Place an order for a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + ApiResponse response = apiInstance.placeOrderWithHttpInfo(order); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Tag.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Tag.md new file mode 100644 index 000000000000..abfde4afb501 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/Tag.md @@ -0,0 +1,15 @@ + + +# Tag + +A tag for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/User.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/User.md new file mode 100644 index 000000000000..426845227bd3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/User.md @@ -0,0 +1,21 @@ + + +# User + +A User who is purchasing from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**username** | **String** | | [optional] | +|**firstName** | **String** | | [optional] | +|**lastName** | **String** | | [optional] | +|**email** | **String** | | [optional] | +|**password** | **String** | | [optional] | +|**phone** | **String** | | [optional] | +|**userStatus** | **Integer** | User Status | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/docs/UserApi.md b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/UserApi.md new file mode 100644 index 000000000000..da72405c908b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/docs/UserApi.md @@ -0,0 +1,1178 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**createUser**](UserApi.md#createUser) | **POST** /user | Create user | +| [**createUserWithHttpInfo**](UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user | +| [**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithArrayInputWithHttpInfo**](UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array | +| [**createUsersWithListInputWithHttpInfo**](UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array | +| [**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user | +| [**deleteUserWithHttpInfo**](UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user | +| [**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name | +| [**getUserByNameWithHttpInfo**](UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name | +| [**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system | +| [**loginUserWithHttpInfo**](UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system | +| [**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session | +| [**logoutUserWithHttpInfo**](UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session | +| [**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user | +| [**updateUserWithHttpInfo**](UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user | + + + +## createUser + +> void createUser(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + apiInstance.createUser(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUserWithHttpInfo + +> ApiResponse createUser createUserWithHttpInfo(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + ApiResponse response = apiInstance.createUserWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithArrayInput + +> void createUsersWithArrayInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithArrayInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithArrayInputWithHttpInfo + +> ApiResponse createUsersWithArrayInput createUsersWithArrayInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithArrayInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithListInput + +> void createUsersWithListInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithListInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithListInputWithHttpInfo + +> ApiResponse createUsersWithListInput createUsersWithListInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithListInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## deleteUser + +> void deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + apiInstance.deleteUser(username); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## deleteUserWithHttpInfo + +> ApiResponse deleteUser deleteUserWithHttpInfo(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + ApiResponse response = apiInstance.deleteUserWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## getUserByName + +> User getUserByName(username) + +Get user by user name + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + User result = apiInstance.getUserByName(username); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +[**User**](User.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## getUserByNameWithHttpInfo + +> ApiResponse getUserByName getUserByNameWithHttpInfo(username) + +Get user by user name + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + ApiResponse response = apiInstance.getUserByNameWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +ApiResponse<[**User**](User.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## loginUser + +> String loginUser(username, password) + +Logs user into the system + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + String result = apiInstance.loginUser(username, password); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +**String** + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + +## loginUserWithHttpInfo + +> ApiResponse loginUser loginUserWithHttpInfo(username, password) + +Logs user into the system + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + ApiResponse response = apiInstance.loginUserWithHttpInfo(username, password); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +ApiResponse<**String**> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + + +## logoutUser + +> void logoutUser() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + apiInstance.logoutUser(); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## logoutUserWithHttpInfo + +> ApiResponse logoutUser logoutUserWithHttpInfo() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + ApiResponse response = apiInstance.logoutUserWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## updateUser + +> void updateUser(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + apiInstance.updateUser(username, user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + +## updateUserWithHttpInfo + +> ApiResponse updateUser updateUserWithHttpInfo(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + ApiResponse response = apiInstance.updateUserWithHttpInfo(username, user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/git_push.sh b/samples/client/petstore/java/native/test-regenerated-fixed3/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/gradle.properties b/samples/client/petstore/java/native/test-regenerated-fixed3/gradle.properties new file mode 100644 index 000000000000..a3408578278a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/gradle.properties @@ -0,0 +1,6 @@ +# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/java/native/test-regenerated-fixed3/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..e6441136f3d4 Binary files /dev/null and b/samples/client/petstore/java/native/test-regenerated-fixed3/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/java/native/test-regenerated-fixed3/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..b82aa23a4f05 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/gradlew b/samples/client/petstore/java/native/test-regenerated-fixed3/gradlew new file mode 100644 index 000000000000..9d0ce634cb11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/gradlew.bat b/samples/client/petstore/java/native/test-regenerated-fixed3/gradlew.bat new file mode 100644 index 000000000000..25da30dbdeee --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/pom.xml b/samples/client/petstore/java/native/test-regenerated-fixed3/pom.xml new file mode 100644 index 000000000000..10a3beca26fb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/pom.xml @@ -0,0 +1,264 @@ + + 4.0.0 + org.openapitools + openapi-java-client + jar + openapi-java-client + 1.0.0 + https://github.com/openapitools/openapi-generator + OpenAPI Java + + scm:git:git@github.com:openapitools/openapi-generator.git + scm:git:git@github.com:openapitools/openapi-generator.git + https://github.com/openapitools/openapi-generator + + + + + Unlicense + https://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + + OpenAPI-Generator Contributors + team@openapitools.org + OpenAPITools.org + http://openapitools.org + + + + + + + maven-enforcer-plugin + 3.1.0 + + + enforce-maven + + enforce + + + + + 3 + + + 11 + + + + + + + + maven-surefire-plugin + 3.2.5 + + + conf/log4j.properties + + -Xms512m -Xmx1500m + methods + 10 + + + + maven-dependency-plugin + 3.3.0 + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + test-jar + + + + + + + + maven-compiler-plugin + 3.10.1 + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.4.1 + + + attach-javadocs + + jar + + + + + + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + + + + .gitignore + + + + + + true + 4 + + + + + + + + + + 1.8 + + true + + + + + + + + + + + + sign-artifacts + + + + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + org.apache.httpcomponents + httpmime + ${httpmime-version} + + + + + org.junit.jupiter + junit-jupiter-api + ${junit-version} + test + + + + + UTF-8 + 11 + 11 + 2.17.1 + 0.2.6 + 1.3.5 + 2.0.2 + 4.5.14 + 5.10.2 + 2.27.2 + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/settings.gradle b/samples/client/petstore/java/native/test-regenerated-fixed3/settings.gradle new file mode 100644 index 000000000000..369ba54a9e06 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "openapi-java-client" \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/AndroidManifest.xml b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..54fbcb3da1e8 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiClient.java new file mode 100644 index 000000000000..f6996146c172 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiClient.java @@ -0,0 +1,457 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.jackson.nullable.JsonNullableModule; + +import java.io.InputStream; +import java.net.URI; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpConnectTimeoutException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static java.nio.charset.StandardCharsets.UTF_8; + +/** + * Configuration and utility class for API clients. + * + *

This class can be constructed and modified, then used to instantiate the + * various API classes. The API classes use the settings in this class to + * configure themselves, but otherwise do not store a link to this class.

+ * + *

This class is mutable and not synchronized, so it is not thread-safe. + * The API classes generated from this are immutable and thread-safe.

+ * + *

The setter methods of this class return the current object to facilitate + * a fluent style of configuration.

+ */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiClient { + + protected HttpClient.Builder builder; + protected ObjectMapper mapper; + protected String scheme; + protected String host; + protected int port; + protected String basePath; + protected Consumer interceptor; + protected Consumer> responseInterceptor; + protected Consumer> asyncResponseInterceptor; + protected Duration readTimeout; + protected Duration connectTimeout; + + public static String valueToString(Object value) { + if (value == null) { + return ""; + } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + return value.toString(); + } + + /** + * URL encode a string in the UTF-8 encoding. + * + * @param s String to encode. + * @return URL-encoded representation of the input string. + */ + public static String urlEncode(String s) { + return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20"); + } + + /** + * Convert a URL query name/value parameter to a list of encoded {@link Pair} + * objects. + * + *

The value can be null, in which case an empty list is returned.

+ * + * @param name The query name parameter. + * @param value The query value, which may not be a collection but may be + * null. + * @return A singleton list of the {@link Pair} objects representing the input + * parameters, which is encoded for use in a URL. If the value is null, an + * empty list is returned. + */ + public static List parameterToPairs(String name, Object value) { + if (name == null || name.isEmpty() || value == null) { + return Collections.emptyList(); + } + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); + } + + /** + * Convert a URL query name/collection parameter to a list of encoded + * {@link Pair} objects. + * + * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). + * @param name The query name parameter. + * @param values A collection of values for the given query name, which may be + * null. + * @return A list of {@link Pair} objects representing the input parameters, + * which is encoded for use in a URL. If the values collection is null, an + * empty list is returned. + */ + public static List parameterToPairs( + String collectionFormat, String name, Collection values) { + if (name == null || name.isEmpty() || values == null || values.isEmpty()) { + return Collections.emptyList(); + } + + // get the collection format (default: csv) + String format = collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; + + // create the params based on the collection format + if ("multi".equals(format)) { + return values.stream() + .map(value -> new Pair(urlEncode(name), urlEncode(valueToString(value)))) + .collect(Collectors.toList()); + } + + String delimiter; + switch(format) { + case "csv": + delimiter = urlEncode(","); + break; + case "ssv": + delimiter = urlEncode(" "); + break; + case "tsv": + delimiter = urlEncode("\t"); + break; + case "pipes": + delimiter = urlEncode("|"); + break; + default: + throw new IllegalArgumentException("Illegal collection format: " + collectionFormat); + } + + StringJoiner joiner = new StringJoiner(delimiter); + for (Object value : values) { + joiner.add(urlEncode(valueToString(value))); + } + + return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); + } + + /** + * Create an instance of ApiClient. + */ + public ApiClient() { + this.builder = createDefaultHttpClientBuilder(); + this.mapper = createDefaultObjectMapper(); + updateBaseUri(getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + /** + * Create an instance of ApiClient. + * + * @param builder Http client builder. + * @param mapper Object mapper. + * @param baseUri Base URI + */ + public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri) { + this.builder = builder; + this.mapper = mapper; + updateBaseUri(baseUri != null ? baseUri : getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + public static ObjectMapper createDefaultObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); + return mapper; + } + + protected String getDefaultBaseUri() { + return "http://petstore.swagger.io/v2"; + } + + public static HttpClient.Builder createDefaultHttpClientBuilder() { + return HttpClient.newBuilder(); + } + + public final void updateBaseUri(String baseUri) { + URI uri = URI.create(baseUri); + scheme = uri.getScheme(); + host = uri.getHost(); + port = uri.getPort(); + basePath = uri.getRawPath(); + } + + /** + * Set a custom {@link HttpClient.Builder} object to use when creating the + * {@link HttpClient} that is used by the API client. + * + * @param builder Custom client builder. + * @return This object. + */ + public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { + this.builder = builder; + return this; + } + + /** + * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. + * + *

The returned object is immutable and thread-safe.

+ * + * @return The HTTP client. + */ + public HttpClient getHttpClient() { + return builder.build(); + } + + /** + * Set a custom {@link ObjectMapper} to serialize and deserialize the request + * and response bodies. + * + * @param mapper Custom object mapper. + * @return This object. + */ + public ApiClient setObjectMapper(ObjectMapper mapper) { + this.mapper = mapper; + return this; + } + + /** + * Get a copy of the current {@link ObjectMapper}. + * + * @return A copy of the current object mapper. + */ + public ObjectMapper getObjectMapper() { + return mapper.copy(); + } + + /** + * Set a custom host name for the target service. + * + * @param host The host name of the target service. + * @return This object. + */ + public ApiClient setHost(String host) { + this.host = host; + return this; + } + + /** + * Set a custom port number for the target service. + * + * @param port The port of the target service. Set this to -1 to reset the + * value to the default for the scheme. + * @return This object. + */ + public ApiClient setPort(int port) { + this.port = port; + return this; + } + + /** + * Set a custom base path for the target service, for example '/v2'. + * + * @param basePath The base path against which the rest of the path is + * resolved. + * @return This object. + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get the base URI to resolve the endpoint paths against. + * + * @return The complete base URI that the rest of the API parameters are + * resolved against. + */ + public String getBaseUri() { + return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath; + } + + /** + * Set a custom scheme for the target service, for example 'https'. + * + * @param scheme The scheme of the target service + * @return This object. + */ + public ApiClient setScheme(String scheme){ + this.scheme = scheme; + return this; + } + + /** + * Set a custom request interceptor. + * + *

A request interceptor is a mechanism for altering each request before it + * is sent. After the request has been fully configured but not yet built, the + * request builder is passed into this function for further modification, + * after which it is sent out.

+ * + *

This is useful for altering the requests in a custom manner, such as + * adding headers. It could also be used for logging and monitoring.

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setRequestInterceptor(Consumer interceptor) { + this.interceptor = interceptor; + return this; + } + + /** + * Get the custom interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer getRequestInterceptor() { + return interceptor; + } + + /** + * Set a custom response interceptor. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setResponseInterceptor(Consumer> interceptor) { + this.responseInterceptor = interceptor; + return this; + } + + /** + * Get the custom response interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getResponseInterceptor() { + return responseInterceptor; + } + + /** + * Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { + this.asyncResponseInterceptor = interceptor; + return this; + } + + /** + * Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getAsyncResponseInterceptor() { + return asyncResponseInterceptor; + } + + /** + * Set the read timeout for the http client. + * + *

This is the value used by default for each request, though it can be + * overridden on a per-request basis with a request interceptor.

+ * + * @param readTimeout The read timeout used by default by the http client. + * Setting this value to null resets the timeout to an + * effectively infinite value. + * @return This object. + */ + public ApiClient setReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; + } + + /** + * Get the read timeout that was set. + * + * @return The read timeout, or null if no timeout was set. Null represents + * an infinite wait time. + */ + public Duration getReadTimeout() { + return readTimeout; + } + /** + * Sets the connect timeout (in milliseconds) for the http client. + * + *

In the case where a new connection needs to be established, if + * the connection cannot be established within the given {@code + * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler) + * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or + * {@link HttpClient#sendAsync(HttpRequest,BodyHandler) + * HttpClient::sendAsync} completes exceptionally with an + * {@code HttpConnectTimeoutException}. If a new connection does not + * need to be established, for example if a connection can be reused + * from a previous request, then this timeout duration has no effect. + * + * @param connectTimeout connection timeout in milliseconds + * + * @return This object. + */ + public ApiClient setConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + this.builder.connectTimeout(connectTimeout); + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public Duration getConnectTimeout() { + return connectTimeout; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiException.java new file mode 100644 index 000000000000..d481fc94ab1f --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiException.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.net.http.HttpHeaders; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + + private int code = 0; + private HttpHeaders responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return Headers as an HttpHeaders object + */ + public HttpHeaders getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiResponse.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiResponse.java new file mode 100644 index 000000000000..5494a9af8da3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ApiResponse.java @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/Configuration.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/Configuration.java new file mode 100644 index 000000000000..b94cbd072ab0 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/Configuration.java @@ -0,0 +1,63 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Configuration { + public static final String VERSION = "1.0.0"; + + private static final AtomicReference defaultApiClient = new AtomicReference<>(); + private static volatile Supplier apiClientFactory = ApiClient::new; + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + ApiClient client = defaultApiClient.get(); + if (client == null) { + client = defaultApiClient.updateAndGet(val -> { + if (val != null) { // changed by another thread + return val; + } + return apiClientFactory.get(); + }); + } + return client; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient.set(apiClient); + } + + /** + * set the callback used to create new ApiClient objects + */ + public static void setApiClientFactory(Supplier factory) { + apiClientFactory = Objects.requireNonNull(factory); + } + + private Configuration() { + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/JSON.java new file mode 100644 index 000000000000..24ebd07afeb8 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/JSON.java @@ -0,0 +1,264 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import org.openapitools.jackson.nullable.JsonNullableModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.client.model.*; + +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = JsonMapper.builder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) + .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) + .defaultDateFormat(new RFC3339DateFormat()) + .addModule(new JavaTimeModule()) + .build(); + JsonNullableModule jnm = new JsonNullableModule(); + mapper.registerModule(jnm); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public ObjectMapper getMapper() { return mapper; } + + /** + * Returns the target model class that should be used to deserialize the input data. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + * + * @return the target model class. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** + * Helper class to register the discriminator mappings. + */ + @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. + * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + * + * @return the target model class. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, + * so it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + * @param visitedClasses The set of classes that have already been visited. + * + * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. + */ + public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map> descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (Class childType : descendants.values()) { + if (isInstanceOf(childType, inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** + * A map of discriminators for all model classes. + */ + private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); + + /** + * A map of oneOf/anyOf descendants for each model class. + */ + private static Map, Map>> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map> descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/Pair.java new file mode 100644 index 000000000000..a25bfacf0228 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/Pair.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pair { + private final String name; + private final String value; + + public Pair(String name, String value) { + this.name = isValidString(name) ? name : ""; + this.value = isValidString(value) ? value : ""; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private static boolean isValidString(String arg) { + return arg != null; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339DateFormat.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339DateFormat.java new file mode 100644 index 000000000000..9e1ec51a5f8e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339DateFormat.java @@ -0,0 +1,58 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.text.DecimalFormat; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse(String source) { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return super.clone(); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 000000000000..f822913c3133 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + private static final long serialVersionUID = 1L; + private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault(); + private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + = JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault(); + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false, // keep zero offset and Z separate since zones explicitly supported + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ, + boolean normalizeZoneId, + boolean readNumericStringsAsTimestamp) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ, + normalizeZoneId, + readNumericStringsAsTimestamp + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 000000000000..3f00b05afebd --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + private static final long serialVersionUID = 1L; + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ServerConfiguration.java new file mode 100644 index 000000000000..c4b9d58bd5a7 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ServerConfiguration.java @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ServerVariable.java new file mode 100644 index 000000000000..30dc73830abf --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/PetApi.java new file mode 100644 index 000000000000..4a7d64d51bd5 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/PetApi.java @@ -0,0 +1,1110 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class PetApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public PetApi() { + this(Configuration.getDefaultApiClient()); + } + + public PetApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPet(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = addPetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPetWithHttpInfo(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("addPet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + deletePet(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + deletePetWithHttpInfo(petId, apiKey, headers); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePetWithHttpInfo(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deletePet", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + if (apiKey != null) { + localVarRequestBuilder.header("api_key", apiKey.toString()); + } + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatus(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatusWithHttpInfo(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByStatus", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByStatus"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "status"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTags(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTagsWithHttpInfo(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByTags", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByTags"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "tags"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetById(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId, headers); + return localVarResponse.getData(); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetByIdWithHttpInfo(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getPetById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePet(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = updatePetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePetWithHttpInfo(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + updatePetWithForm(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + updatePetWithFormWithHttpInfo(petId, name, status, headers); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithFormWithHttpInfo(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePetWithForm", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + List formValues = new ArrayList<>(); + if (name != null) { + formValues.add(new BasicNameValuePair("name", name.toString())); + } + if (status != null) { + formValues.add(new BasicNameValuePair("status", status.toString())); + } + HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8); + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()))); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFile(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file, headers); + return localVarResponse.getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFileWithHttpInfo(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("uploadFile", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}/uploadImage" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create(); + boolean hasFiles = false; + if (additionalMetadata != null) { + multiPartBuilder.addTextBody("additionalMetadata", additionalMetadata.toString()); + } + multiPartBuilder.addBinaryBody("file", _file); + hasFiles = true; + HttpEntity entity = multiPartBuilder.build(); + HttpRequest.BodyPublisher formDataPublisher; + if (hasFiles) { + Pipe pipe; + try { + pipe = Pipe.open(); + } catch (IOException e) { + throw new RuntimeException(e); + } + new Thread(() -> { + try (OutputStream outputStream = Channels.newOutputStream(pipe.sink())) { + entity.writeTo(outputStream); + } catch (IOException e) { + e.printStackTrace(); + } + }).start(); + formDataPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> Channels.newInputStream(pipe.source())); + } else { + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + formDataPublisher = HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray())); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", formDataPublisher); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/StoreApi.java new file mode 100644 index 000000000000..63a40aa0e047 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/StoreApi.java @@ -0,0 +1,535 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import org.openapitools.client.model.Order; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class StoreApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public StoreApi() { + this(Configuration.getDefaultApiClient()); + } + + public StoreApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiException { + deleteOrder(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + deleteOrderWithHttpInfo(orderId, headers); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrderWithHttpInfo(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteOrder", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory() throws ApiException { + return getInventory(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory(Map headers) throws ApiException { + ApiResponse> localVarResponse = getInventoryWithHttpInfo(headers); + return localVarResponse.getData(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { + return getInventoryWithHttpInfo(null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getInventory", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getInventoryRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/inventory"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderById(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId, headers); + return localVarResponse.getData(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderByIdWithHttpInfo(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getOrderById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrder(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + ApiResponse localVarResponse = placeOrderWithHttpInfo(order, headers); + return localVarResponse.getData(); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrderWithHttpInfo(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("placeOrder", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + // verify the required parameter 'order' is set + if (order == null) { + throw new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(order); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/UserApi.java new file mode 100644 index 000000000000..636380546e71 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/api/UserApi.java @@ -0,0 +1,995 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class UserApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public UserApi() { + this(Configuration.getDefaultApiClient()); + } + + public UserApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user) throws ApiException { + createUser(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + createUserWithHttpInfo(user, headers); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user) throws ApiException { + return createUserWithHttpInfo(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user) throws ApiException { + createUsersWithArrayInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithArrayInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithArrayInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithArray"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user) throws ApiException { + createUsersWithListInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithListInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithListInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithList"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username) throws ApiException { + deleteUser(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + deleteUserWithHttpInfo(username, headers); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUserWithHttpInfo(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByName(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + ApiResponse localVarResponse = getUserByNameWithHttpInfo(username, headers); + return localVarResponse.getData(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByNameWithHttpInfo(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getUserByName", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUser(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + ApiResponse localVarResponse = loginUserWithHttpInfo(username, password, headers); + return localVarResponse.getData(); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUserWithHttpInfo(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("loginUser", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); + } + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/login"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "username"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("username", username)); + localVarQueryParameterBaseName = "password"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("password", password)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs out current logged in user session + * + * @throws ApiException if fails to make API call + */ + public void logoutUser() throws ApiException { + logoutUser(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void logoutUser(Map headers) throws ApiException { + logoutUserWithHttpInfo(headers); + } + + /** + * Logs out current logged in user session + * + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo() throws ApiException { + return logoutUserWithHttpInfo(null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("logoutUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder logoutUserRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/logout"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + updateUser(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + updateUserWithHttpInfo(username, user, headers); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUserWithHttpInfo(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updateUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); + } + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling updateUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000000..1be882a5a25f --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.lang.reflect.Type; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Category.java new file mode 100644 index 000000000000..00ab496b51e0 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Category.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A category for a pet + */ +@JsonPropertyOrder({ + Category.JSON_PROPERTY_ID, + Category.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Category { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Category() { + } + + public Category id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Category name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Category object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/ModelApiResponse.java new file mode 100644 index 000000000000..78606a6eea9b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -0,0 +1,223 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * Describes the result of uploading an image resource + */ +@JsonPropertyOrder({ + ModelApiResponse.JSON_PROPERTY_CODE, + ModelApiResponse.JSON_PROPERTY_TYPE, + ModelApiResponse.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ModelApiResponse { + public static final String JSON_PROPERTY_CODE = "code"; + @javax.annotation.Nullable + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + @javax.annotation.Nullable + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + @javax.annotation.Nullable + private String message; + + public ModelApiResponse() { + } + + public ModelApiResponse code(@javax.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(@javax.annotation.Nullable Integer code) { + this.code = code; + } + + + public ModelApiResponse type(@javax.annotation.Nullable String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(@javax.annotation.Nullable String type) { + this.type = type; + } + + + public ModelApiResponse message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + /** + * Return true if this ApiResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format("%scode%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getCode())))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format("%stype%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getType())))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format("%smessage%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getMessage())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Order.java new file mode 100644 index 000000000000..dd17ee540177 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Order.java @@ -0,0 +1,369 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.time.OffsetDateTime; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * An order for a pets from the pet store + */ +@JsonPropertyOrder({ + Order.JSON_PROPERTY_ID, + Order.JSON_PROPERTY_PET_ID, + Order.JSON_PROPERTY_QUANTITY, + Order.JSON_PROPERTY_SHIP_DATE, + Order.JSON_PROPERTY_STATUS, + Order.JSON_PROPERTY_COMPLETE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Order { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_PET_ID = "petId"; + @javax.annotation.Nullable + private Long petId; + + public static final String JSON_PROPERTY_QUANTITY = "quantity"; + @javax.annotation.Nullable + private Integer quantity; + + public static final String JSON_PROPERTY_SHIP_DATE = "shipDate"; + @javax.annotation.Nullable + private OffsetDateTime shipDate; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED(String.valueOf("placed")), + + APPROVED(String.valueOf("approved")), + + DELIVERED(String.valueOf("delivered")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public static final String JSON_PROPERTY_COMPLETE = "complete"; + @javax.annotation.Nullable + private Boolean complete = false; + + public Order() { + } + + public Order id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Order petId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getPetId() { + return petId; + } + + + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPetId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + } + + + public Order quantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getQuantity() { + return quantity; + } + + + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setQuantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + } + + + public Order shipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getShipDate() { + return shipDate; + } + + + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setShipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + } + + + public Order status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + public Order complete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getComplete() { + return complete; + } + + + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComplete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + } + + + /** + * Return true if this Order object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `petId` to the URL query string + if (getPetId() != null) { + joiner.add(String.format("%spetId%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPetId())))); + } + + // add `quantity` to the URL query string + if (getQuantity() != null) { + joiner.add(String.format("%squantity%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getQuantity())))); + } + + // add `shipDate` to the URL query string + if (getShipDate() != null) { + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getShipDate())))); + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + // add `complete` to the URL query string + if (getComplete() != null) { + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getComplete())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Pet.java new file mode 100644 index 000000000000..31d5e511b5e7 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Pet.java @@ -0,0 +1,397 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A pet for sale in the pet store + */ +@JsonPropertyOrder({ + Pet.JSON_PROPERTY_ID, + Pet.JSON_PROPERTY_CATEGORY, + Pet.JSON_PROPERTY_NAME, + Pet.JSON_PROPERTY_PHOTO_URLS, + Pet.JSON_PROPERTY_TAGS, + Pet.JSON_PROPERTY_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pet { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_CATEGORY = "category"; + @javax.annotation.Nullable + private Category category; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nonnull + private String name; + + public static final String JSON_PROPERTY_PHOTO_URLS = "photoUrls"; + @javax.annotation.Nonnull + private List photoUrls = new ArrayList<>(); + + public static final String JSON_PROPERTY_TAGS = "tags"; + @javax.annotation.Nullable + private List tags = new ArrayList<>(); + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE(String.valueOf("available")), + + PENDING(String.valueOf("pending")), + + SOLD(String.valueOf("sold")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public Pet() { + } + + public Pet id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Pet category(@javax.annotation.Nullable Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Category getCategory() { + return category; + } + + + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCategory(@javax.annotation.Nullable Category category) { + this.category = category; + } + + + public Pet name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public Pet photoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + if (this.photoUrls == null) { + this.photoUrls = new ArrayList<>(); + } + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getPhotoUrls() { + return photoUrls; + } + + + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setPhotoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + } + + + public Pet tags(@javax.annotation.Nullable List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTags() { + return tags; + } + + + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTags(@javax.annotation.Nullable List tags) { + this.tags = tags; + } + + + public Pet status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + /** + * Return true if this Pet object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `category` to the URL query string + if (getCategory() != null) { + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + // add `photoUrls` to the URL query string + if (getPhotoUrls() != null) { + for (int i = 0; i < getPhotoUrls().size(); i++) { + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + ApiClient.urlEncode(ApiClient.valueToString(getPhotoUrls().get(i))))); + } + } + + // add `tags` to the URL query string + if (getTags() != null) { + for (int i = 0; i < getTags().size(); i++) { + if (getTags().get(i) != null) { + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Tag.java new file mode 100644 index 000000000000..bda2f24ac2c2 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/Tag.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A tag for a pet + */ +@JsonPropertyOrder({ + Tag.JSON_PROPERTY_ID, + Tag.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Tag { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Tag() { + } + + public Tag id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Tag name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Tag object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/User.java new file mode 100644 index 000000000000..4c5a5db4e5d1 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/main/java/org/openapitools/client/model/User.java @@ -0,0 +1,403 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A User who is purchasing from the pet store + */ +@JsonPropertyOrder({ + User.JSON_PROPERTY_ID, + User.JSON_PROPERTY_USERNAME, + User.JSON_PROPERTY_FIRST_NAME, + User.JSON_PROPERTY_LAST_NAME, + User.JSON_PROPERTY_EMAIL, + User.JSON_PROPERTY_PASSWORD, + User.JSON_PROPERTY_PHONE, + User.JSON_PROPERTY_USER_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:09:56.830832+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class User { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_USERNAME = "username"; + @javax.annotation.Nullable + private String username; + + public static final String JSON_PROPERTY_FIRST_NAME = "firstName"; + @javax.annotation.Nullable + private String firstName; + + public static final String JSON_PROPERTY_LAST_NAME = "lastName"; + @javax.annotation.Nullable + private String lastName; + + public static final String JSON_PROPERTY_EMAIL = "email"; + @javax.annotation.Nullable + private String email; + + public static final String JSON_PROPERTY_PASSWORD = "password"; + @javax.annotation.Nullable + private String password; + + public static final String JSON_PROPERTY_PHONE = "phone"; + @javax.annotation.Nullable + private String phone; + + public static final String JSON_PROPERTY_USER_STATUS = "userStatus"; + @javax.annotation.Nullable + private Integer userStatus; + + public User() { + } + + public User id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public User username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUsername() { + return username; + } + + + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + + public User firstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstName() { + return firstName; + } + + + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + } + + + public User lastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLastName() { + return lastName; + } + + + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + } + + + public User email(@javax.annotation.Nullable String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEmail() { + return email; + } + + + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEmail(@javax.annotation.Nullable String email) { + this.email = email; + } + + + public User password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPassword() { + return password; + } + + + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + + public User phone(@javax.annotation.Nullable String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPhone() { + return phone; + } + + + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPhone(@javax.annotation.Nullable String phone) { + this.phone = phone; + } + + + public User userStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getUserStatus() { + return userStatus; + } + + + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUserStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + } + + + /** + * Return true if this User object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `username` to the URL query string + if (getUsername() != null) { + joiner.add(String.format("%susername%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUsername())))); + } + + // add `firstName` to the URL query string + if (getFirstName() != null) { + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getFirstName())))); + } + + // add `lastName` to the URL query string + if (getLastName() != null) { + joiner.add(String.format("%slastName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getLastName())))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add(String.format("%semail%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getEmail())))); + } + + // add `password` to the URL query string + if (getPassword() != null) { + joiner.add(String.format("%spassword%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPassword())))); + } + + // add `phone` to the URL query string + if (getPhone() != null) { + joiner.add(String.format("%sphone%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPhone())))); + } + + // add `userStatus` to the URL query string + if (getUserStatus() != null) { + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUserStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/PetApiTest.java new file mode 100644 index 000000000000..f725ba246938 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -0,0 +1,180 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for PetApi + */ +@Disabled +public class PetApiTest { + + private final PetApi api = new PetApi(); + + + /** + * Add a new pet to the store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void addPetTest() throws ApiException { + Pet pet = null; + Pet response = + api.addPet(pet); + + // TODO: test validations + } + + /** + * Deletes a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deletePetTest() throws ApiException { + Long petId = null; + String apiKey = null; + + api.deletePet(petId, apiKey); + + // TODO: test validations + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByStatusTest() throws ApiException { + List status = null; + List response = + api.findPetsByStatus(status); + + // TODO: test validations + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByTagsTest() throws ApiException { + List tags = null; + List response = + api.findPetsByTags(tags); + + // TODO: test validations + } + + /** + * Find pet by ID + * + * Returns a single pet + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getPetByIdTest() throws ApiException { + Long petId = null; + Pet response = + api.getPetById(petId); + + // TODO: test validations + } + + /** + * Update an existing pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetTest() throws ApiException { + Pet pet = null; + Pet response = + api.updatePet(pet); + + // TODO: test validations + } + + /** + * Updates a pet in the store with form data + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetWithFormTest() throws ApiException { + Long petId = null; + String name = null; + String status = null; + + api.updatePetWithForm(petId, name, status); + + // TODO: test validations + } + + /** + * uploads an image + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileTest() throws ApiException { + Long petId = null; + String additionalMetadata = null; + File _file = null; + ModelApiResponse response = + api.uploadFile(petId, additionalMetadata, _file); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/StoreApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/StoreApiTest.java new file mode 100644 index 000000000000..be318cab8b1e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/StoreApiTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import org.openapitools.client.model.Order; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for StoreApi + */ +@Disabled +public class StoreApiTest { + + private final StoreApi api = new StoreApi(); + + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteOrderTest() throws ApiException { + String orderId = null; + + api.deleteOrder(orderId); + + // TODO: test validations + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getInventoryTest() throws ApiException { + Map response = + api.getInventory(); + + // TODO: test validations + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getOrderByIdTest() throws ApiException { + Long orderId = null; + Order response = + api.getOrderById(orderId); + + // TODO: test validations + } + + /** + * Place an order for a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void placeOrderTest() throws ApiException { + Order order = null; + Order response = + api.placeOrder(order); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/UserApiTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/UserApiTest.java new file mode 100644 index 000000000000..2b2b7a60fd21 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/api/UserApiTest.java @@ -0,0 +1,175 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for UserApi + */ +@Disabled +public class UserApiTest { + + private final UserApi api = new UserApi(); + + + /** + * Create user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUserTest() throws ApiException { + User user = null; + + api.createUser(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() throws ApiException { + List user = null; + + api.createUsersWithArrayInput(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() throws ApiException { + List user = null; + + api.createUsersWithListInput(user); + + // TODO: test validations + } + + /** + * Delete user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteUserTest() throws ApiException { + String username = null; + + api.deleteUser(username); + + // TODO: test validations + } + + /** + * Get user by user name + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserByNameTest() throws ApiException { + String username = null; + User response = + api.getUserByName(username); + + // TODO: test validations + } + + /** + * Logs user into the system + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void loginUserTest() throws ApiException { + String username = null; + String password = null; + String response = + api.loginUser(username, password); + + // TODO: test validations + } + + /** + * Logs out current logged in user session + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void logoutUserTest() throws ApiException { + + api.logoutUser(); + + // TODO: test validations + } + + /** + * Updated user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserTest() throws ApiException { + String username = null; + User user = null; + + api.updateUser(username, user); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/CategoryTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/CategoryTest.java new file mode 100644 index 000000000000..ae23ab433a50 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/CategoryTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Category + */ +class CategoryTest { + private final Category model = new Category(); + + /** + * Model tests for Category + */ + @Test + void testCategory() { + // TODO: test Category + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java new file mode 100644 index 000000000000..c846563bfe1f --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java @@ -0,0 +1,64 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ModelApiResponse + */ +class ModelApiResponseTest { + private final ModelApiResponse model = new ModelApiResponse(); + + /** + * Model tests for ModelApiResponse + */ + @Test + void testModelApiResponse() { + // TODO: test ModelApiResponse + } + + /** + * Test the property 'code' + */ + @Test + void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + void messageTest() { + // TODO: test message + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/OrderTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/OrderTest.java new file mode 100644 index 000000000000..4d8d136809eb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/OrderTest.java @@ -0,0 +1,89 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Order + */ +class OrderTest { + private final Order model = new Order(); + + /** + * Model tests for Order + */ + @Test + void testOrder() { + // TODO: test Order + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'petId' + */ + @Test + void petIdTest() { + // TODO: test petId + } + + /** + * Test the property 'quantity' + */ + @Test + void quantityTest() { + // TODO: test quantity + } + + /** + * Test the property 'shipDate' + */ + @Test + void shipDateTest() { + // TODO: test shipDate + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + + /** + * Test the property 'complete' + */ + @Test + void completeTest() { + // TODO: test complete + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/PetTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/PetTest.java new file mode 100644 index 000000000000..84aff8adbf96 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/PetTest.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Pet + */ +class PetTest { + private final Pet model = new Pet(); + + /** + * Model tests for Pet + */ + @Test + void testPet() { + // TODO: test Pet + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'category' + */ + @Test + void categoryTest() { + // TODO: test category + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'photoUrls' + */ + @Test + void photoUrlsTest() { + // TODO: test photoUrls + } + + /** + * Test the property 'tags' + */ + @Test + void tagsTest() { + // TODO: test tags + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/TagTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/TagTest.java new file mode 100644 index 000000000000..6bd8b9f5035e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/TagTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Tag + */ +class TagTest { + private final Tag model = new Tag(); + + /** + * Model tests for Tag + */ + @Test + void testTag() { + // TODO: test Tag + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/UserTest.java b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/UserTest.java new file mode 100644 index 000000000000..40f4892264aa --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated-fixed3/src/test/java/org/openapitools/client/model/UserTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for User + */ +class UserTest { + private final User model = new User(); + + /** + * Model tests for User + */ + @Test + void testUser() { + // TODO: test User + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'username' + */ + @Test + void usernameTest() { + // TODO: test username + } + + /** + * Test the property 'firstName' + */ + @Test + void firstNameTest() { + // TODO: test firstName + } + + /** + * Test the property 'lastName' + */ + @Test + void lastNameTest() { + // TODO: test lastName + } + + /** + * Test the property 'email' + */ + @Test + void emailTest() { + // TODO: test email + } + + /** + * Test the property 'password' + */ + @Test + void passwordTest() { + // TODO: test password + } + + /** + * Test the property 'phone' + */ + @Test + void phoneTest() { + // TODO: test phone + } + + /** + * Test the property 'userStatus' + */ + @Test + void userStatusTest() { + // TODO: test userStatus + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/.github/workflows/maven.yml b/samples/client/petstore/java/native/test-regenerated/.github/workflows/maven.yml new file mode 100644 index 000000000000..460f78bfd1b2 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/.github/workflows/maven.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build OpenAPI Petstore + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 17, 21 ] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml diff --git a/samples/client/petstore/java/native/test-regenerated/.gitignore b/samples/client/petstore/java/native/test-regenerated/.gitignore new file mode 100644 index 000000000000..a530464afa1b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/.gitignore @@ -0,0 +1,21 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/samples/client/petstore/java/native/test-regenerated/.openapi-generator-ignore b/samples/client/petstore/java/native/test-regenerated/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/java/native/test-regenerated/.openapi-generator/FILES b/samples/client/petstore/java/native/test-regenerated/.openapi-generator/FILES new file mode 100644 index 000000000000..57d506c4c50b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/.openapi-generator/FILES @@ -0,0 +1,56 @@ +.github/workflows/maven.yml +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +build.gradle +build.sbt +docs/Category.md +docs/ModelApiResponse.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +git_push.sh +gradle.properties +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/AndroidManifest.xml +src/main/java/org/openapitools/client/ApiClient.java +src/main/java/org/openapitools/client/ApiException.java +src/main/java/org/openapitools/client/ApiResponse.java +src/main/java/org/openapitools/client/Configuration.java +src/main/java/org/openapitools/client/JSON.java +src/main/java/org/openapitools/client/Pair.java +src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java +src/main/java/org/openapitools/client/ServerConfiguration.java +src/main/java/org/openapitools/client/ServerVariable.java +src/main/java/org/openapitools/client/api/PetApi.java +src/main/java/org/openapitools/client/api/StoreApi.java +src/main/java/org/openapitools/client/api/UserApi.java +src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java +src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ModelApiResponse.java +src/main/java/org/openapitools/client/model/Order.java +src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Tag.java +src/main/java/org/openapitools/client/model/User.java +src/test/java/org/openapitools/client/api/PetApiTest.java +src/test/java/org/openapitools/client/api/StoreApiTest.java +src/test/java/org/openapitools/client/api/UserApiTest.java +src/test/java/org/openapitools/client/model/CategoryTest.java +src/test/java/org/openapitools/client/model/ModelApiResponseTest.java +src/test/java/org/openapitools/client/model/OrderTest.java +src/test/java/org/openapitools/client/model/PetTest.java +src/test/java/org/openapitools/client/model/TagTest.java +src/test/java/org/openapitools/client/model/UserTest.java diff --git a/samples/client/petstore/java/native/test-regenerated/.openapi-generator/VERSION b/samples/client/petstore/java/native/test-regenerated/.openapi-generator/VERSION new file mode 100644 index 000000000000..fc74d6ceba8e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.15.0-SNAPSHOT diff --git a/samples/client/petstore/java/native/test-regenerated/.travis.yml b/samples/client/petstore/java/native/test-regenerated/.travis.yml new file mode 100644 index 000000000000..c94647479234 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/.travis.yml @@ -0,0 +1,16 @@ +# +# Generated by: https://openapi-generator.tech +# +language: java +jdk: + - oraclejdk11 +before_install: + # ensure gradlew has proper permission + - chmod a+x ./gradlew +script: + # test using maven + - mvn test + # uncomment below to test using gradle + # - gradle test + # uncomment below to test using sbt + # - sbt test diff --git a/samples/client/petstore/java/native/test-regenerated/README.md b/samples/client/petstore/java/native/test-regenerated/README.md new file mode 100644 index 000000000000..82fe1fdd26ea --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/README.md @@ -0,0 +1,197 @@ +# openapi-java-client + +OpenAPI Petstore + +- API version: 1.0.0 + +- Build date: 2025-07-08T21:01:56.363494+07:00[Asia/Bangkok] + +- Generator version: 7.15.0-SNAPSHOT + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + +## Requirements + +Building the API client library requires: + +1. Java 11+ +2. Maven/Gradle + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn clean deploy +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + org.openapitools + openapi-java-client + 1.0.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "org.openapitools:openapi-java-client:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +- `target/openapi-java-client-1.0.0.jar` +- `target/lib/*.jar` + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import org.openapitools.client.*; +import org.openapitools.client.model.*; +import org.openapitools.client.api.PetApi; + +public class PetApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + // Configure clients using the `defaultClient` object, such as + // overriding the host and port, timeout, etc. + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetWithHttpInfo**](docs/PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**deletePetWithHttpInfo**](docs/PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByStatusWithHttpInfo**](docs/PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**findPetsByTagsWithHttpInfo**](docs/PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**getPetByIdWithHttpInfo**](docs/PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithHttpInfo**](docs/PetApi.md#updatePetWithHttpInfo) | **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* | [**updatePetWithFormWithHttpInfo**](docs/PetApi.md#updatePetWithFormWithHttpInfo) | **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* | [**uploadFileWithHttpInfo**](docs/PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**deleteOrderWithHttpInfo**](docs/StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryWithHttpInfo**](docs/StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**getOrderByIdWithHttpInfo**](docs/StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*StoreApi* | [**placeOrderWithHttpInfo**](docs/StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUserWithHttpInfo**](docs/UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithArrayInputWithHttpInfo**](docs/UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**createUsersWithListInputWithHttpInfo**](docs/UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**deleteUserWithHttpInfo**](docs/UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**getUserByNameWithHttpInfo**](docs/UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**loginUserWithHttpInfo**](docs/UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**logoutUserWithHttpInfo**](docs/UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user +*UserApi* | [**updateUserWithHttpInfo**](docs/UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Category](docs/Category.md) + - [ModelApiResponse](docs/ModelApiResponse.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### petstore_auth + + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + + +### api_key + + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. +However, the instances of the api clients created from the `ApiClient` are thread-safe and can be re-used. + +## Author + + + diff --git a/samples/client/petstore/java/native/test-regenerated/api/openapi.yaml b/samples/client/petstore/java/native/test-regenerated/api/openapi.yaml new file mode 100644 index 000000000000..9b1b54b9454b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/api/openapi.yaml @@ -0,0 +1,865 @@ +openapi: 3.0.0 +info: + description: "This is a sample server Petstore server. For this sample, you can\ + \ use the api key `special-key` to test the authorization filters." + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://petstore.swagger.io/v2 +tags: +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user +paths: + /pet: + post: + description: "" + operationId: addPet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + put: + description: "" + operationId: updatePet + requestBody: + $ref: "#/components/requestBodies/Pet" + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + "405": + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /pet/findByStatus: + get: + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - description: Status values that need to be considered for filter + explode: false + in: query + name: status + required: true + schema: + items: + default: available + enum: + - available + - pending + - sold + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid status value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by status + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/findByTags: + get: + deprecated: true + description: "Multiple tags can be provided with comma separated strings. Use\ + \ tag1, tag2, tag3 for testing." + operationId: findPetsByTags + parameters: + - description: Tags to filter by + explode: false + in: query + name: tags + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + application/json: + schema: + items: + $ref: "#/components/schemas/Pet" + type: array + description: successful operation + "400": + description: Invalid tag value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: + - application/json + - application/xml + /pet/{petId}: + delete: + description: "" + operationId: deletePet + parameters: + - explode: false + in: header + name: api_key + required: false + schema: + type: string + style: simple + - description: Pet id to delete + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "400": + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet + tags: + - pet + x-accepts: + - application/json + get: + description: Returns a single pet + operationId: getPetById + parameters: + - description: ID of pet to return + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Pet" + application/json: + schema: + $ref: "#/components/schemas/Pet" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: + - application/json + - application/xml + post: + description: "" + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/updatePetWithForm_request" + responses: + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-content-type: application/x-www-form-urlencoded + x-accepts: + - application/json + /pet/{petId}/uploadImage: + post: + description: "" + operationId: uploadFile + 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/uploadFile_request" + 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 + x-content-type: multipart/form-data + x-accepts: + - application/json + /store/inventory: + get: + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + "200": + content: + application/json: + schema: + additionalProperties: + format: int32 + type: integer + type: object + description: successful operation + security: + - api_key: [] + summary: Returns pet inventories by status + tags: + - store + x-accepts: + - application/json + /store/order: + post: + description: "" + operationId: placeOrder + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/Order" + description: order placed for purchasing the pet + required: true + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-content-type: application/json + x-accepts: + - application/json + - application/xml + /store/order/{orderId}: + delete: + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - description: ID of the order that needs to be deleted + explode: false + in: path + name: orderId + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Delete purchase order by ID + tags: + - store + x-accepts: + - application/json + get: + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generate exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + explode: false + in: path + name: orderId + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/Order" + application/json: + schema: + $ref: "#/components/schemas/Order" + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Find purchase order by ID + tags: + - store + x-accepts: + - application/json + - application/xml + /user: + post: + description: This can only be done by the logged in user. + operationId: createUser + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Created user object + required: true + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Create user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithArray: + post: + description: "" + operationId: createUsersWithArrayInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/createWithList: + post: + description: "" + operationId: createUsersWithListInput + requestBody: + $ref: "#/components/requestBodies/UserArray" + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-content-type: application/json + x-accepts: + - application/json + /user/login: + get: + description: "" + operationId: loginUser + parameters: + - description: The user name for login + explode: true + in: query + name: username + required: true + schema: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + style: form + - description: The password for login in clear text + explode: true + in: query + name: password + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + Set-Cookie: + description: Cookie authentication key for use with the `api_key` apiKey + authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple + X-Rate-Limit: + description: calls per hour allowed by the user + explode: false + schema: + format: int32 + type: integer + style: simple + X-Expires-After: + description: date in UTC when token expires + explode: false + schema: + format: date-time + type: string + style: simple + "400": + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: + - application/json + - application/xml + /user/logout: + get: + description: "" + operationId: logoutUser + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Logs out current logged in user session + tags: + - user + x-accepts: + - application/json + /user/{username}: + delete: + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - description: The name that needs to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid username supplied + "404": + description: User not found + security: + - api_key: [] + summary: Delete user + tags: + - user + x-accepts: + - application/json + get: + description: "" + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: "#/components/schemas/User" + application/json: + schema: + $ref: "#/components/schemas/User" + description: successful operation + "400": + description: Invalid username supplied + "404": + description: User not found + summary: Get user by user name + tags: + - user + x-accepts: + - application/json + - application/xml + put: + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - description: name that need to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/User" + description: Updated user object + required: true + responses: + "400": + description: Invalid user supplied + "404": + description: User not found + security: + - api_key: [] + summary: Updated user + tags: + - user + x-content-type: application/json + x-accepts: + - application/json +components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: "#/components/schemas/User" + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + application/xml: + schema: + $ref: "#/components/schemas/Pet" + description: Pet object that needs to be added to the store + required: true + schemas: + ApiResponse: + description: Describes the result of uploading an image resource + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + title: An uploaded response + type: object + Pet: + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + category: + $ref: "#/components/schemas/Category" + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: "#/components/schemas/Tag" + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + title: a Pet + type: object + xml: + name: Pet + Order: + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + title: Pet Order + type: object + xml: + name: Order + User: + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + description: User Status + format: int32 + type: integer + title: a User + type: object + xml: + name: User + Category: + description: A category for a pet + example: + name: name + id: 6 + properties: + id: + format: int64 + type: integer + name: + pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string + title: Pet category + type: object + xml: + name: Category + Tag: + description: A tag for a pet + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + title: Pet Tag + type: object + xml: + name: Tag + updatePetWithForm_request: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + uploadFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object + securitySchemes: + petstore_auth: + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + type: oauth2 + api_key: + in: header + name: api_key + type: apiKey + diff --git a/samples/client/petstore/java/native/test-regenerated/build.gradle b/samples/client/petstore/java/native/test-regenerated/build.gradle new file mode 100644 index 000000000000..56fa470fb767 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/build.gradle @@ -0,0 +1,109 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'com.diffplug.spotless' + +group = 'org.openapitools' +version = '1.0.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} + +apply plugin: 'java' +apply plugin: 'maven-publish' + +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 + +// Some text from the schema is copy pasted into the source files as UTF-8 +// but the default still seems to be to use platform encoding +tasks.withType(JavaCompile) { + configure(options) { + options.encoding = 'UTF-8' + } +} +javadoc { + options.encoding = 'UTF-8' +} + +publishing { + publications { + maven(MavenPublication) { + artifactId = 'openapi-java-client' + from components.java + } + } +} + +task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath +} + +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + + +ext { + jackson_version = "2.17.1" + jakarta_annotation_version = "1.3.5" + beanvalidation_version = "2.0.2" + junit_version = "5.10.2" + httpmime_version = "4.5.13" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" + implementation "org.openapitools:jackson-databind-nullable:0.2.1" + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + implementation "org.apache.httpcomponents:httpmime:$httpmime_version" + testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + removeUnusedImports() + importOrder() + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/build.sbt b/samples/client/petstore/java/native/test-regenerated/build.sbt new file mode 100644 index 000000000000..464090415c47 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/build.sbt @@ -0,0 +1 @@ +# TODO diff --git a/samples/client/petstore/java/native/test-regenerated/docs/Category.md b/samples/client/petstore/java/native/test-regenerated/docs/Category.md new file mode 100644 index 000000000000..a7fc939d252e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/Category.md @@ -0,0 +1,15 @@ + + +# Category + +A category for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/ModelApiResponse.md b/samples/client/petstore/java/native/test-regenerated/docs/ModelApiResponse.md new file mode 100644 index 000000000000..cd7e3c400be6 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/ModelApiResponse.md @@ -0,0 +1,16 @@ + + +# ModelApiResponse + +Describes the result of uploading an image resource + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/Order.md b/samples/client/petstore/java/native/test-regenerated/docs/Order.md new file mode 100644 index 000000000000..0c33059b8b6a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/Order.md @@ -0,0 +1,29 @@ + + +# Order + +An order for a pets from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**petId** | **Long** | | [optional] | +|**quantity** | **Integer** | | [optional] | +|**shipDate** | **OffsetDateTime** | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] | +|**complete** | **Boolean** | | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| PLACED | "placed" | +| APPROVED | "approved" | +| DELIVERED | "delivered" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/Pet.md b/samples/client/petstore/java/native/test-regenerated/docs/Pet.md new file mode 100644 index 000000000000..8bb363301232 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/Pet.md @@ -0,0 +1,29 @@ + + +# Pet + +A pet for sale in the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**category** | [**Category**](Category.md) | | [optional] | +|**name** | **String** | | | +|**photoUrls** | **List<String>** | | | +|**tags** | [**List<Tag>**](Tag.md) | | [optional] | +|**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] | + + + +## Enum: StatusEnum + +| Name | Value | +|---- | -----| +| AVAILABLE | "available" | +| PENDING | "pending" | +| SOLD | "sold" | + + + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/PetApi.md b/samples/client/petstore/java/native/test-regenerated/docs/PetApi.md new file mode 100644 index 000000000000..51f089e85389 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/PetApi.md @@ -0,0 +1,1212 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store | +| [**addPetWithHttpInfo**](PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store | +| [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet | +| [**deletePetWithHttpInfo**](PetApi.md#deletePetWithHttpInfo) | **DELETE** /pet/{petId} | Deletes a pet | +| [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByStatusWithHttpInfo**](PetApi.md#findPetsByStatusWithHttpInfo) | **GET** /pet/findByStatus | Finds Pets by status | +| [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags | +| [**findPetsByTagsWithHttpInfo**](PetApi.md#findPetsByTagsWithHttpInfo) | **GET** /pet/findByTags | Finds Pets by tags | +| [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID | +| [**getPetByIdWithHttpInfo**](PetApi.md#getPetByIdWithHttpInfo) | **GET** /pet/{petId} | Find pet by ID | +| [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet | +| [**updatePetWithHttpInfo**](PetApi.md#updatePetWithHttpInfo) | **PUT** /pet | Update an existing pet | +| [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**updatePetWithFormWithHttpInfo**](PetApi.md#updatePetWithFormWithHttpInfo) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image | +| [**uploadFileWithHttpInfo**](PetApi.md#uploadFileWithHttpInfo) | **POST** /pet/{petId}/uploadImage | uploads an image | + + + +## addPet + +> Pet addPet(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.addPet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + +## addPetWithHttpInfo + +> ApiResponse addPet addPetWithHttpInfo(pet) + +Add a new pet to the store + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.addPetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + + +## deletePet + +> void deletePet(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + apiInstance.deletePet(petId, apiKey); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + +## deletePetWithHttpInfo + +> ApiResponse deletePet deletePetWithHttpInfo(petId, apiKey) + +Deletes a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | + try { + ApiResponse response = apiInstance.deletePetWithHttpInfo(petId, apiKey); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + + +## findPetsByStatus + +> List findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + List result = apiInstance.findPetsByStatus(status); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + +## findPetsByStatusWithHttpInfo + +> ApiResponse> findPetsByStatus findPetsByStatusWithHttpInfo(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + try { + ApiResponse> response = apiInstance.findPetsByStatusWithHttpInfo(status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + + +## findPetsByTags + +> List findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + List result = apiInstance.findPetsByTags(tags); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +[**List<Pet>**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + +## findPetsByTagsWithHttpInfo + +> ApiResponse> findPetsByTags findPetsByTagsWithHttpInfo(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + List tags = Arrays.asList(); // List | Tags to filter by + try { + ApiResponse> response = apiInstance.findPetsByTagsWithHttpInfo(tags); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **tags** | [**List<String>**](String.md)| Tags to filter by | | + +### Return type + +ApiResponse<[**List<Pet>**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + + +## getPetById + +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + Pet result = apiInstance.getPetById(petId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +## getPetByIdWithHttpInfo + +> ApiResponse getPetById getPetByIdWithHttpInfo(petId) + +Find pet by ID + +Returns a single pet + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to return + try { + ApiResponse response = apiInstance.getPetByIdWithHttpInfo(petId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to return | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + + +## updatePet + +> Pet updatePet(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + Pet result = apiInstance.updatePet(pet); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +[**Pet**](Pet.md) + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + +## updatePetWithHttpInfo + +> ApiResponse updatePet updatePetWithHttpInfo(pet) + +Update an existing pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store + try { + ApiResponse response = apiInstance.updatePetWithHttpInfo(pet); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | + +### Return type + +ApiResponse<[**Pet**](Pet.md)> + + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + + +## updatePetWithForm + +> void updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + apiInstance.updatePetWithForm(petId, name, status); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +## updatePetWithFormWithHttpInfo + +> ApiResponse updatePetWithForm updatePetWithFormWithHttpInfo(petId, name, status) + +Updates a pet in the store with form data + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet + try { + ApiResponse response = apiInstance.updatePetWithFormWithHttpInfo(petId, name, status); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | + +### Return type + + +ApiResponse + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + + +## uploadFile + +> ModelApiResponse uploadFile(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, _file); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +[**ModelApiResponse**](ModelApiResponse.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 | - | + +## uploadFileWithHttpInfo + +> ApiResponse uploadFile uploadFileWithHttpInfo(petId, additionalMetadata, _file) + +uploads an image + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.PetApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + PetApi apiInstance = new PetApi(defaultClient); + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload + try { + ApiResponse response = apiInstance.uploadFileWithHttpInfo(petId, additionalMetadata, _file); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | + +### Return type + +ApiResponse<[**ModelApiResponse**](ModelApiResponse.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 | - | + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/StoreApi.md b/samples/client/petstore/java/native/test-regenerated/docs/StoreApi.md new file mode 100644 index 000000000000..7dfbbe315c11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/StoreApi.md @@ -0,0 +1,564 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**deleteOrderWithHttpInfo**](StoreApi.md#deleteOrderWithHttpInfo) | **DELETE** /store/order/{orderId} | Delete purchase order by ID | +| [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status | +| [**getInventoryWithHttpInfo**](StoreApi.md#getInventoryWithHttpInfo) | **GET** /store/inventory | Returns pet inventories by status | +| [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**getOrderByIdWithHttpInfo**](StoreApi.md#getOrderByIdWithHttpInfo) | **GET** /store/order/{orderId} | Find purchase order by ID | +| [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet | +| [**placeOrderWithHttpInfo**](StoreApi.md#placeOrderWithHttpInfo) | **POST** /store/order | Place an order for a pet | + + + +## deleteOrder + +> void deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + apiInstance.deleteOrder(orderId); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## deleteOrderWithHttpInfo + +> ApiResponse deleteOrder deleteOrderWithHttpInfo(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + try { + ApiResponse response = apiInstance.deleteOrderWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **String**| ID of the order that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## getInventory + +> Map getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + Map result = apiInstance.getInventory(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**Map<String, Integer>** + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +## getInventoryWithHttpInfo + +> ApiResponse> getInventory getInventoryWithHttpInfo() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + StoreApi apiInstance = new StoreApi(defaultClient); + try { + ApiResponse> response = apiInstance.getInventoryWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +ApiResponse<**Map<String, Integer>**> + + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + +## getOrderById + +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + Order result = apiInstance.getOrderById(orderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +## getOrderByIdWithHttpInfo + +> ApiResponse getOrderById getOrderByIdWithHttpInfo(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Long orderId = 56L; // Long | ID of pet that needs to be fetched + try { + ApiResponse response = apiInstance.getOrderByIdWithHttpInfo(orderId); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **orderId** | **Long**| ID of pet that needs to be fetched | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + + +## placeOrder + +> Order placeOrder(order) + +Place an order for a pet + + + +### 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.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + Order result = apiInstance.placeOrder(order); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +[**Order**](Order.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + +## placeOrderWithHttpInfo + +> ApiResponse placeOrder placeOrderWithHttpInfo(order) + +Place an order for a pet + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.StoreApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + StoreApi apiInstance = new StoreApi(defaultClient); + Order order = new Order(); // Order | order placed for purchasing the pet + try { + ApiResponse response = apiInstance.placeOrderWithHttpInfo(order); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **order** | [**Order**](Order.md)| order placed for purchasing the pet | | + +### Return type + +ApiResponse<[**Order**](Order.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/Tag.md b/samples/client/petstore/java/native/test-regenerated/docs/Tag.md new file mode 100644 index 000000000000..abfde4afb501 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/Tag.md @@ -0,0 +1,15 @@ + + +# Tag + +A tag for a pet + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/User.md b/samples/client/petstore/java/native/test-regenerated/docs/User.md new file mode 100644 index 000000000000..426845227bd3 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/User.md @@ -0,0 +1,21 @@ + + +# User + +A User who is purchasing from the pet store + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | | [optional] | +|**username** | **String** | | [optional] | +|**firstName** | **String** | | [optional] | +|**lastName** | **String** | | [optional] | +|**email** | **String** | | [optional] | +|**password** | **String** | | [optional] | +|**phone** | **String** | | [optional] | +|**userStatus** | **Integer** | User Status | [optional] | + + + diff --git a/samples/client/petstore/java/native/test-regenerated/docs/UserApi.md b/samples/client/petstore/java/native/test-regenerated/docs/UserApi.md new file mode 100644 index 000000000000..da72405c908b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/docs/UserApi.md @@ -0,0 +1,1178 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**createUser**](UserApi.md#createUser) | **POST** /user | Create user | +| [**createUserWithHttpInfo**](UserApi.md#createUserWithHttpInfo) | **POST** /user | Create user | +| [**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithArrayInputWithHttpInfo**](UserApi.md#createUsersWithArrayInputWithHttpInfo) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array | +| [**createUsersWithListInputWithHttpInfo**](UserApi.md#createUsersWithListInputWithHttpInfo) | **POST** /user/createWithList | Creates list of users with given input array | +| [**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user | +| [**deleteUserWithHttpInfo**](UserApi.md#deleteUserWithHttpInfo) | **DELETE** /user/{username} | Delete user | +| [**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name | +| [**getUserByNameWithHttpInfo**](UserApi.md#getUserByNameWithHttpInfo) | **GET** /user/{username} | Get user by user name | +| [**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system | +| [**loginUserWithHttpInfo**](UserApi.md#loginUserWithHttpInfo) | **GET** /user/login | Logs user into the system | +| [**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session | +| [**logoutUserWithHttpInfo**](UserApi.md#logoutUserWithHttpInfo) | **GET** /user/logout | Logs out current logged in user session | +| [**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user | +| [**updateUserWithHttpInfo**](UserApi.md#updateUserWithHttpInfo) | **PUT** /user/{username} | Updated user | + + + +## createUser + +> void createUser(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + apiInstance.createUser(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUserWithHttpInfo + +> ApiResponse createUser createUserWithHttpInfo(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + User user = new User(); // User | Created user object + try { + ApiResponse response = apiInstance.createUserWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**User**](User.md)| Created user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithArrayInput + +> void createUsersWithArrayInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithArrayInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithArrayInputWithHttpInfo + +> ApiResponse createUsersWithArrayInput createUsersWithArrayInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithArrayInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## createUsersWithListInput + +> void createUsersWithListInput(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + apiInstance.createUsersWithListInput(user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## createUsersWithListInputWithHttpInfo + +> ApiResponse createUsersWithListInput createUsersWithListInputWithHttpInfo(user) + +Creates list of users with given input array + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + List user = Arrays.asList(); // List | List of user object + try { + ApiResponse response = apiInstance.createUsersWithListInputWithHttpInfo(user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **user** | [**List<User>**](User.md)| List of user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## deleteUser + +> void deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + apiInstance.deleteUser(username); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## deleteUserWithHttpInfo + +> ApiResponse deleteUser deleteUserWithHttpInfo(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be deleted + try { + ApiResponse response = apiInstance.deleteUserWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be deleted | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## getUserByName + +> User getUserByName(username) + +Get user by user name + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + User result = apiInstance.getUserByName(username); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +[**User**](User.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +## getUserByNameWithHttpInfo + +> ApiResponse getUserByName getUserByNameWithHttpInfo(username) + +Get user by user name + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + try { + ApiResponse response = apiInstance.getUserByNameWithHttpInfo(username); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +ApiResponse<[**User**](User.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + + +## loginUser + +> String loginUser(username, password) + +Logs user into the system + + + +### 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.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + String result = apiInstance.loginUser(username, password); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +**String** + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + +## loginUserWithHttpInfo + +> ApiResponse loginUser loginUserWithHttpInfo(username, password) + +Logs user into the system + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text + try { + ApiResponse response = apiInstance.loginUserWithHttpInfo(username, password); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | + +### Return type + +ApiResponse<**String**> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + + +## logoutUser + +> void logoutUser() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + apiInstance.logoutUser(); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +## logoutUserWithHttpInfo + +> ApiResponse logoutUser logoutUserWithHttpInfo() + +Logs out current logged in user session + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + try { + ApiResponse response = apiInstance.logoutUserWithHttpInfo(); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + + +## updateUser + +> void updateUser(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + apiInstance.updateUser(username, user); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +null (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + +## updateUserWithHttpInfo + +> ApiResponse updateUser updateUserWithHttpInfo(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.*; +import org.openapitools.client.models.*; +import org.openapitools.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io/v2"); + + // Configure API key authorization: api_key + ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); + api_key.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //api_key.setApiKeyPrefix("Token"); + + UserApi apiInstance = new UserApi(defaultClient); + String username = "username_example"; // String | name that need to be deleted + User user = new User(); // User | Updated user object + try { + ApiResponse response = apiInstance.updateUserWithHttpInfo(username, user); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **username** | **String**| name that need to be deleted | | +| **user** | [**User**](User.md)| Updated user object | | + +### Return type + + +ApiResponse + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + diff --git a/samples/client/petstore/java/native/test-regenerated/git_push.sh b/samples/client/petstore/java/native/test-regenerated/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/java/native/test-regenerated/gradle.properties b/samples/client/petstore/java/native/test-regenerated/gradle.properties new file mode 100644 index 000000000000..a3408578278a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/gradle.properties @@ -0,0 +1,6 @@ +# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android diff --git a/samples/client/petstore/java/native/test-regenerated/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/java/native/test-regenerated/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..e6441136f3d4 Binary files /dev/null and b/samples/client/petstore/java/native/test-regenerated/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/java/native/test-regenerated/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/java/native/test-regenerated/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..b82aa23a4f05 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/client/petstore/java/native/test-regenerated/gradlew b/samples/client/petstore/java/native/test-regenerated/gradlew new file mode 100644 index 000000000000..9d0ce634cb11 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/client/petstore/java/native/test-regenerated/gradlew.bat b/samples/client/petstore/java/native/test-regenerated/gradlew.bat new file mode 100644 index 000000000000..25da30dbdeee --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/java/native/test-regenerated/pom.xml b/samples/client/petstore/java/native/test-regenerated/pom.xml new file mode 100644 index 000000000000..10a3beca26fb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/pom.xml @@ -0,0 +1,264 @@ + + 4.0.0 + org.openapitools + openapi-java-client + jar + openapi-java-client + 1.0.0 + https://github.com/openapitools/openapi-generator + OpenAPI Java + + scm:git:git@github.com:openapitools/openapi-generator.git + scm:git:git@github.com:openapitools/openapi-generator.git + https://github.com/openapitools/openapi-generator + + + + + Unlicense + https://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + + OpenAPI-Generator Contributors + team@openapitools.org + OpenAPITools.org + http://openapitools.org + + + + + + + maven-enforcer-plugin + 3.1.0 + + + enforce-maven + + enforce + + + + + 3 + + + 11 + + + + + + + + maven-surefire-plugin + 3.2.5 + + + conf/log4j.properties + + -Xms512m -Xmx1500m + methods + 10 + + + + maven-dependency-plugin + 3.3.0 + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + test-jar + + + + + + + + maven-compiler-plugin + 3.10.1 + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.4.1 + + + attach-javadocs + + jar + + + + + + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + + + + .gitignore + + + + + + true + 4 + + + + + + + + + + 1.8 + + true + + + + + + + + + + + + sign-artifacts + + + + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + org.apache.httpcomponents + httpmime + ${httpmime-version} + + + + + org.junit.jupiter + junit-jupiter-api + ${junit-version} + test + + + + + UTF-8 + 11 + 11 + 2.17.1 + 0.2.6 + 1.3.5 + 2.0.2 + 4.5.14 + 5.10.2 + 2.27.2 + + diff --git a/samples/client/petstore/java/native/test-regenerated/settings.gradle b/samples/client/petstore/java/native/test-regenerated/settings.gradle new file mode 100644 index 000000000000..369ba54a9e06 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "openapi-java-client" \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/AndroidManifest.xml b/samples/client/petstore/java/native/test-regenerated/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..54fbcb3da1e8 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiClient.java new file mode 100644 index 000000000000..a4138950264a --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiClient.java @@ -0,0 +1,457 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.jackson.nullable.JsonNullableModule; + +import java.io.InputStream; +import java.net.URI; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpConnectTimeoutException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static java.nio.charset.StandardCharsets.UTF_8; + +/** + * Configuration and utility class for API clients. + * + *

This class can be constructed and modified, then used to instantiate the + * various API classes. The API classes use the settings in this class to + * configure themselves, but otherwise do not store a link to this class.

+ * + *

This class is mutable and not synchronized, so it is not thread-safe. + * The API classes generated from this are immutable and thread-safe.

+ * + *

The setter methods of this class return the current object to facilitate + * a fluent style of configuration.

+ */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiClient { + + protected HttpClient.Builder builder; + protected ObjectMapper mapper; + protected String scheme; + protected String host; + protected int port; + protected String basePath; + protected Consumer interceptor; + protected Consumer> responseInterceptor; + protected Consumer> asyncResponseInterceptor; + protected Duration readTimeout; + protected Duration connectTimeout; + + public static String valueToString(Object value) { + if (value == null) { + return ""; + } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + return value.toString(); + } + + /** + * URL encode a string in the UTF-8 encoding. + * + * @param s String to encode. + * @return URL-encoded representation of the input string. + */ + public static String urlEncode(String s) { + return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20"); + } + + /** + * Convert a URL query name/value parameter to a list of encoded {@link Pair} + * objects. + * + *

The value can be null, in which case an empty list is returned.

+ * + * @param name The query name parameter. + * @param value The query value, which may not be a collection but may be + * null. + * @return A singleton list of the {@link Pair} objects representing the input + * parameters, which is encoded for use in a URL. If the value is null, an + * empty list is returned. + */ + public static List parameterToPairs(String name, Object value) { + if (name == null || name.isEmpty() || value == null) { + return Collections.emptyList(); + } + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); + } + + /** + * Convert a URL query name/collection parameter to a list of encoded + * {@link Pair} objects. + * + * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). + * @param name The query name parameter. + * @param values A collection of values for the given query name, which may be + * null. + * @return A list of {@link Pair} objects representing the input parameters, + * which is encoded for use in a URL. If the values collection is null, an + * empty list is returned. + */ + public static List parameterToPairs( + String collectionFormat, String name, Collection values) { + if (name == null || name.isEmpty() || values == null || values.isEmpty()) { + return Collections.emptyList(); + } + + // get the collection format (default: csv) + String format = collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; + + // create the params based on the collection format + if ("multi".equals(format)) { + return values.stream() + .map(value -> new Pair(urlEncode(name), urlEncode(valueToString(value)))) + .collect(Collectors.toList()); + } + + String delimiter; + switch(format) { + case "csv": + delimiter = urlEncode(","); + break; + case "ssv": + delimiter = urlEncode(" "); + break; + case "tsv": + delimiter = urlEncode("\t"); + break; + case "pipes": + delimiter = urlEncode("|"); + break; + default: + throw new IllegalArgumentException("Illegal collection format: " + collectionFormat); + } + + StringJoiner joiner = new StringJoiner(delimiter); + for (Object value : values) { + joiner.add(urlEncode(valueToString(value))); + } + + return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); + } + + /** + * Create an instance of ApiClient. + */ + public ApiClient() { + this.builder = createDefaultHttpClientBuilder(); + this.mapper = createDefaultObjectMapper(); + updateBaseUri(getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + /** + * Create an instance of ApiClient. + * + * @param builder Http client builder. + * @param mapper Object mapper. + * @param baseUri Base URI + */ + public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri) { + this.builder = builder; + this.mapper = mapper; + updateBaseUri(baseUri != null ? baseUri : getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + public static ObjectMapper createDefaultObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); + return mapper; + } + + protected String getDefaultBaseUri() { + return "http://petstore.swagger.io/v2"; + } + + public static HttpClient.Builder createDefaultHttpClientBuilder() { + return HttpClient.newBuilder(); + } + + public final void updateBaseUri(String baseUri) { + URI uri = URI.create(baseUri); + scheme = uri.getScheme(); + host = uri.getHost(); + port = uri.getPort(); + basePath = uri.getRawPath(); + } + + /** + * Set a custom {@link HttpClient.Builder} object to use when creating the + * {@link HttpClient} that is used by the API client. + * + * @param builder Custom client builder. + * @return This object. + */ + public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { + this.builder = builder; + return this; + } + + /** + * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. + * + *

The returned object is immutable and thread-safe.

+ * + * @return The HTTP client. + */ + public HttpClient getHttpClient() { + return builder.build(); + } + + /** + * Set a custom {@link ObjectMapper} to serialize and deserialize the request + * and response bodies. + * + * @param mapper Custom object mapper. + * @return This object. + */ + public ApiClient setObjectMapper(ObjectMapper mapper) { + this.mapper = mapper; + return this; + } + + /** + * Get a copy of the current {@link ObjectMapper}. + * + * @return A copy of the current object mapper. + */ + public ObjectMapper getObjectMapper() { + return mapper.copy(); + } + + /** + * Set a custom host name for the target service. + * + * @param host The host name of the target service. + * @return This object. + */ + public ApiClient setHost(String host) { + this.host = host; + return this; + } + + /** + * Set a custom port number for the target service. + * + * @param port The port of the target service. Set this to -1 to reset the + * value to the default for the scheme. + * @return This object. + */ + public ApiClient setPort(int port) { + this.port = port; + return this; + } + + /** + * Set a custom base path for the target service, for example '/v2'. + * + * @param basePath The base path against which the rest of the path is + * resolved. + * @return This object. + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get the base URI to resolve the endpoint paths against. + * + * @return The complete base URI that the rest of the API parameters are + * resolved against. + */ + public String getBaseUri() { + return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath; + } + + /** + * Set a custom scheme for the target service, for example 'https'. + * + * @param scheme The scheme of the target service + * @return This object. + */ + public ApiClient setScheme(String scheme){ + this.scheme = scheme; + return this; + } + + /** + * Set a custom request interceptor. + * + *

A request interceptor is a mechanism for altering each request before it + * is sent. After the request has been fully configured but not yet built, the + * request builder is passed into this function for further modification, + * after which it is sent out.

+ * + *

This is useful for altering the requests in a custom manner, such as + * adding headers. It could also be used for logging and monitoring.

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setRequestInterceptor(Consumer interceptor) { + this.interceptor = interceptor; + return this; + } + + /** + * Get the custom interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer getRequestInterceptor() { + return interceptor; + } + + /** + * Set a custom response interceptor. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setResponseInterceptor(Consumer> interceptor) { + this.responseInterceptor = interceptor; + return this; + } + + /** + * Get the custom response interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getResponseInterceptor() { + return responseInterceptor; + } + + /** + * Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { + this.asyncResponseInterceptor = interceptor; + return this; + } + + /** + * Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getAsyncResponseInterceptor() { + return asyncResponseInterceptor; + } + + /** + * Set the read timeout for the http client. + * + *

This is the value used by default for each request, though it can be + * overridden on a per-request basis with a request interceptor.

+ * + * @param readTimeout The read timeout used by default by the http client. + * Setting this value to null resets the timeout to an + * effectively infinite value. + * @return This object. + */ + public ApiClient setReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; + } + + /** + * Get the read timeout that was set. + * + * @return The read timeout, or null if no timeout was set. Null represents + * an infinite wait time. + */ + public Duration getReadTimeout() { + return readTimeout; + } + /** + * Sets the connect timeout (in milliseconds) for the http client. + * + *

In the case where a new connection needs to be established, if + * the connection cannot be established within the given {@code + * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler) + * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or + * {@link HttpClient#sendAsync(HttpRequest,BodyHandler) + * HttpClient::sendAsync} completes exceptionally with an + * {@code HttpConnectTimeoutException}. If a new connection does not + * need to be established, for example if a connection can be reused + * from a previous request, then this timeout duration has no effect. + * + * @param connectTimeout connection timeout in milliseconds + * + * @return This object. + */ + public ApiClient setConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + this.builder.connectTimeout(connectTimeout); + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public Duration getConnectTimeout() { + return connectTimeout; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiException.java new file mode 100644 index 000000000000..4193b3153684 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiException.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.net.http.HttpHeaders; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + + private int code = 0; + private HttpHeaders responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return Headers as an HttpHeaders object + */ + public HttpHeaders getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiResponse.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiResponse.java new file mode 100644 index 000000000000..56d4eb47c6d8 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ApiResponse.java @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/Configuration.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/Configuration.java new file mode 100644 index 000000000000..fd0f5b05dd29 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/Configuration.java @@ -0,0 +1,63 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Configuration { + public static final String VERSION = "1.0.0"; + + private static final AtomicReference defaultApiClient = new AtomicReference<>(); + private static volatile Supplier apiClientFactory = ApiClient::new; + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + ApiClient client = defaultApiClient.get(); + if (client == null) { + client = defaultApiClient.updateAndGet(val -> { + if (val != null) { // changed by another thread + return val; + } + return apiClientFactory.get(); + }); + } + return client; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient.set(apiClient); + } + + /** + * set the callback used to create new ApiClient objects + */ + public static void setApiClientFactory(Supplier factory) { + apiClientFactory = Objects.requireNonNull(factory); + } + + private Configuration() { + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/JSON.java new file mode 100644 index 000000000000..470a66b18d70 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/JSON.java @@ -0,0 +1,264 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import org.openapitools.jackson.nullable.JsonNullableModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.client.model.*; + +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = JsonMapper.builder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) + .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) + .defaultDateFormat(new RFC3339DateFormat()) + .addModule(new JavaTimeModule()) + .build(); + JsonNullableModule jnm = new JsonNullableModule(); + mapper.registerModule(jnm); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public ObjectMapper getMapper() { return mapper; } + + /** + * Returns the target model class that should be used to deserialize the input data. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + * + * @return the target model class. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** + * Helper class to register the discriminator mappings. + */ + @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. + * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + * + * @return the target model class. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, + * so it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + * @param visitedClasses The set of classes that have already been visited. + * + * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. + */ + public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map> descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (Class childType : descendants.values()) { + if (isInstanceOf(childType, inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** + * A map of discriminators for all model classes. + */ + private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); + + /** + * A map of oneOf/anyOf descendants for each model class. + */ + private static Map, Map>> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map> descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/Pair.java new file mode 100644 index 000000000000..686212386a91 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/Pair.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pair { + private final String name; + private final String value; + + public Pair(String name, String value) { + this.name = isValidString(name) ? name : ""; + this.value = isValidString(value) ? value : ""; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private static boolean isValidString(String arg) { + return arg != null; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339DateFormat.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339DateFormat.java new file mode 100644 index 000000000000..4a1cc1478c3e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339DateFormat.java @@ -0,0 +1,58 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.text.DecimalFormat; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse(String source) { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return super.clone(); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 000000000000..ffbce13c0522 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + private static final long serialVersionUID = 1L; + private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault(); + private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + = JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault(); + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false, // keep zero offset and Z separate since zones explicitly supported + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ, + boolean normalizeZoneId, + boolean readNumericStringsAsTimestamp) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ, + normalizeZoneId, + readNumericStringsAsTimestamp + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 000000000000..493a16ff9214 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + private static final long serialVersionUID = 1L; + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ServerConfiguration.java new file mode 100644 index 000000000000..264a86be63ea --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ServerConfiguration.java @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ServerVariable.java new file mode 100644 index 000000000000..fbe910ab7910 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/PetApi.java new file mode 100644 index 000000000000..511fb066bd41 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/PetApi.java @@ -0,0 +1,1110 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class PetApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public PetApi() { + this(Configuration.getDefaultApiClient()); + } + + public PetApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPet(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet addPet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = addPetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return addPetWithHttpInfo(pet, null); + } + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("addPet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder addPetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePet(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deletePet(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + deletePetWithHttpInfo(petId, apiKey, headers); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey) throws ApiException { + return deletePetWithHttpInfo(petId, apiKey, null); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deletePet", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deletePetRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String apiKey, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + if (apiKey != null) { + localVarRequestBuilder.header("api_key", apiKey.toString()); + } + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatus(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + */ + public List findPetsByStatus(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status) throws ApiException { + return findPetsByStatusWithHttpInfo(status, null); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByStatus", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByStatusRequestBuilder(@javax.annotation.Nonnull List status, Map headers) throws ApiException { + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByStatus"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "status"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTags(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return List<Pet> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public List findPetsByTags(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags, headers); + return localVarResponse.getData(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags) throws ApiException { + return findPetsByTagsWithHttpInfo(tags, null); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("findPetsByTags", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder findPetsByTagsRequestBuilder(@javax.annotation.Nonnull List tags, Map headers) throws ApiException { + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/findByTags"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "tags"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetById(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet getPetById(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId, headers); + return localVarResponse.getData(); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId) throws ApiException { + return getPetByIdWithHttpInfo(petId, null); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getPetById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getPetByIdRequestBuilder(@javax.annotation.Nonnull Long petId, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePet(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return Pet + * @throws ApiException if fails to make API call + */ + public Pet updatePet(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + ApiResponse localVarResponse = updatePetWithHttpInfo(pet, headers); + return localVarResponse.getData(); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet) throws ApiException { + return updatePetWithHttpInfo(pet, null); + } + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePet", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetRequestBuilder(@javax.annotation.Nonnull Pet pet, Map headers) throws ApiException { + // verify the required parameter 'pet' is set + if (pet == null) { + throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithForm(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updatePetWithForm(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + updatePetWithFormWithHttpInfo(petId, name, status, headers); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status) throws ApiException { + return updatePetWithFormWithHttpInfo(petId, name, status, null); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updatePetWithForm", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updatePetWithFormRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String name, @javax.annotation.Nullable String status, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + List formValues = new ArrayList<>(); + if (name != null) { + formValues.add(new BasicNameValuePair("name", name.toString())); + } + if (status != null) { + formValues.add(new BasicNameValuePair("status", status.toString())); + } + HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8); + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()))); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFile(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ModelApiResponse + * @throws ApiException if fails to make API call + */ + public ModelApiResponse uploadFile(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file, headers); + return localVarResponse.getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file) throws ApiException { + return uploadFileWithHttpInfo(petId, additionalMetadata, _file, null); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param _file file to upload (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("uploadFile", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder uploadFileRequestBuilder(@javax.annotation.Nonnull Long petId, @javax.annotation.Nullable String additionalMetadata, @javax.annotation.Nullable File _file, Map headers) throws ApiException { + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/pet/{petId}/uploadImage" + .replace("{petId}", ApiClient.urlEncode(petId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create(); + boolean hasFiles = false; + if (additionalMetadata != null) { + multiPartBuilder.addTextBody("additionalMetadata", additionalMetadata.toString()); + } + multiPartBuilder.addBinaryBody("file", _file); + hasFiles = true; + HttpEntity entity = multiPartBuilder.build(); + HttpRequest.BodyPublisher formDataPublisher; + if (hasFiles) { + Pipe pipe; + try { + pipe = Pipe.open(); + } catch (IOException e) { + throw new RuntimeException(e); + } + new Thread(() -> { + try (OutputStream outputStream = Channels.newOutputStream(pipe.sink())) { + entity.writeTo(outputStream); + } catch (IOException e) { + e.printStackTrace(); + } + }).start(); + formDataPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> Channels.newInputStream(pipe.source())); + } else { + ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream(); + try { + entity.writeTo(formOutputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + formDataPublisher = HttpRequest.BodyPublishers + .ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray())); + } + localVarRequestBuilder + .header("Content-Type", entity.getContentType().getValue()) + .method("POST", formDataPublisher); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/StoreApi.java new file mode 100644 index 000000000000..41e4650c8be9 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/StoreApi.java @@ -0,0 +1,535 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import org.openapitools.client.model.Order; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class StoreApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public StoreApi() { + this(Configuration.getDefaultApiClient()); + } + + public StoreApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrder(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteOrder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + deleteOrderWithHttpInfo(orderId, headers); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId) throws ApiException { + return deleteOrderWithHttpInfo(orderId, null); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteOrder", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteOrderRequestBuilder(@javax.annotation.Nonnull String orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory() throws ApiException { + return getInventory(, null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return Map<String, Integer> + * @throws ApiException if fails to make API call + */ + public Map getInventory(Map headers) throws ApiException { + ApiResponse> localVarResponse = getInventoryWithHttpInfo(headers); + return localVarResponse.getData(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { + return getInventoryWithHttpInfo(, null); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @param headers Optional headers to include in the request + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getInventoryRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getInventory", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getInventoryRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/inventory"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderById(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order getOrderById(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + ApiResponse localVarResponse = getOrderByIdWithHttpInfo(orderId, headers); + return localVarResponse.getData(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId) throws ApiException { + return getOrderByIdWithHttpInfo(orderId, null); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getOrderByIdRequestBuilder(orderId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getOrderById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getOrderByIdRequestBuilder(@javax.annotation.Nonnull Long orderId, Map headers) throws ApiException { + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order/{orderId}" + .replace("{orderId}", ApiClient.urlEncode(orderId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrder(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return Order + * @throws ApiException if fails to make API call + */ + public Order placeOrder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + ApiResponse localVarResponse = placeOrderWithHttpInfo(order, headers); + return localVarResponse.getData(); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order) throws ApiException { + return placeOrderWithHttpInfo(order, null); + } + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = placeOrderRequestBuilder(order, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("placeOrder", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull Order order, Map headers) throws ApiException { + // verify the required parameter 'order' is set + if (order == null) { + throw new ApiException(400, "Missing the required parameter 'order' when calling placeOrder"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/store/order"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(order); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/UserApi.java new file mode 100644 index 000000000000..cb97fa693bd2 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/api/UserApi.java @@ -0,0 +1,995 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class UserApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public UserApi() { + this(Configuration.getDefaultApiClient()); + } + + public UserApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user) throws ApiException { + return createUser(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUser(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + createUserWithHttpInfo(user, headers); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user) throws ApiException { + return createUserWithHttpInfo(user, null); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param user Created user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUserRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUserRequestBuilder(@javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithArrayInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithArrayInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithArrayInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithArrayInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithArrayInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithArrayInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithArrayInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithArray"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInput(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void createUsersWithListInput(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + createUsersWithListInputWithHttpInfo(user, headers); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user) throws ApiException { + return createUsersWithListInputWithHttpInfo(user, null); + } + + /** + * Creates list of users with given input array + * + * @param user List of user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = createUsersWithListInputRequestBuilder(user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("createUsersWithListInput", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder createUsersWithListInputRequestBuilder(@javax.annotation.Nonnull List user, Map headers) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling createUsersWithListInput"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/createWithList"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUser(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void deleteUser(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + deleteUserWithHttpInfo(username, headers); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return deleteUserWithHttpInfo(username, null); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteUserRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteUserRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByName(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return User + * @throws ApiException if fails to make API call + */ + public User getUserByName(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + ApiResponse localVarResponse = getUserByNameWithHttpInfo(username, headers); + return localVarResponse.getData(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username) throws ApiException { + return getUserByNameWithHttpInfo(username, null); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getUserByNameRequestBuilder(username, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getUserByName", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getUserByNameRequestBuilder(@javax.annotation.Nonnull String username, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUser(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return String + * @throws ApiException if fails to make API call + */ + public String loginUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + ApiResponse localVarResponse = loginUserWithHttpInfo(username, password, headers); + return localVarResponse.getData(); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password) throws ApiException { + return loginUserWithHttpInfo(username, password, null); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = loginUserRequestBuilder(username, password, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("loginUser", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder loginUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); + } + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/login"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "username"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("username", username)); + localVarQueryParameterBaseName = "password"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("password", password)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/xml, application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Logs out current logged in user session + * + * @throws ApiException if fails to make API call + */ + public void logoutUser() throws ApiException { + return logoutUser(, null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void logoutUser(Map headers) throws ApiException { + logoutUserWithHttpInfo(headers); + } + + /** + * Logs out current logged in user session + * + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo() throws ApiException { + return logoutUserWithHttpInfo(, null); + } + + /** + * Logs out current logged in user session + * + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo(Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = logoutUserRequestBuilder(headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("logoutUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder logoutUserRequestBuilder(Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/logout"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUser(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @throws ApiException if fails to make API call + */ + public void updateUser(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + updateUserWithHttpInfo(username, user, headers); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user) throws ApiException { + return updateUserWithHttpInfo(username, user, null); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param user Updated user object (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = updateUserRequestBuilder(username, user, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("updateUser", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User user, Map headers) throws ApiException { + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); + } + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException(400, "Missing the required parameter 'user' when calling updateUser"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/user/{username}" + .replace("{username}", ApiClient.urlEncode(username.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(user); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + localVarRequestBuilder.header(entry.getKey(), entry.getValue()); + } + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000000..501529ca63e6 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.lang.reflect.Type; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Category.java new file mode 100644 index 000000000000..ba2fe0b9697b --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Category.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A category for a pet + */ +@JsonPropertyOrder({ + Category.JSON_PROPERTY_ID, + Category.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Category { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Category() { + } + + public Category id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Category name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Category object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/ModelApiResponse.java new file mode 100644 index 000000000000..c5e83d11778e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -0,0 +1,223 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * Describes the result of uploading an image resource + */ +@JsonPropertyOrder({ + ModelApiResponse.JSON_PROPERTY_CODE, + ModelApiResponse.JSON_PROPERTY_TYPE, + ModelApiResponse.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class ModelApiResponse { + public static final String JSON_PROPERTY_CODE = "code"; + @javax.annotation.Nullable + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + @javax.annotation.Nullable + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + @javax.annotation.Nullable + private String message; + + public ModelApiResponse() { + } + + public ModelApiResponse code(@javax.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(@javax.annotation.Nullable Integer code) { + this.code = code; + } + + + public ModelApiResponse type(@javax.annotation.Nullable String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(@javax.annotation.Nullable String type) { + this.type = type; + } + + + public ModelApiResponse message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + + /** + * Return true if this ApiResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format("%scode%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getCode())))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format("%stype%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getType())))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format("%smessage%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getMessage())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Order.java new file mode 100644 index 000000000000..5fb9bc260adf --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Order.java @@ -0,0 +1,369 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.time.OffsetDateTime; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * An order for a pets from the pet store + */ +@JsonPropertyOrder({ + Order.JSON_PROPERTY_ID, + Order.JSON_PROPERTY_PET_ID, + Order.JSON_PROPERTY_QUANTITY, + Order.JSON_PROPERTY_SHIP_DATE, + Order.JSON_PROPERTY_STATUS, + Order.JSON_PROPERTY_COMPLETE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Order { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_PET_ID = "petId"; + @javax.annotation.Nullable + private Long petId; + + public static final String JSON_PROPERTY_QUANTITY = "quantity"; + @javax.annotation.Nullable + private Integer quantity; + + public static final String JSON_PROPERTY_SHIP_DATE = "shipDate"; + @javax.annotation.Nullable + private OffsetDateTime shipDate; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED(String.valueOf("placed")), + + APPROVED(String.valueOf("approved")), + + DELIVERED(String.valueOf("delivered")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public static final String JSON_PROPERTY_COMPLETE = "complete"; + @javax.annotation.Nullable + private Boolean complete = false; + + public Order() { + } + + public Order id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Order petId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getPetId() { + return petId; + } + + + @JsonProperty(JSON_PROPERTY_PET_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPetId(@javax.annotation.Nullable Long petId) { + this.petId = petId; + } + + + public Order quantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getQuantity() { + return quantity; + } + + + @JsonProperty(JSON_PROPERTY_QUANTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setQuantity(@javax.annotation.Nullable Integer quantity) { + this.quantity = quantity; + } + + + public Order shipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getShipDate() { + return shipDate; + } + + + @JsonProperty(JSON_PROPERTY_SHIP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setShipDate(@javax.annotation.Nullable OffsetDateTime shipDate) { + this.shipDate = shipDate; + } + + + public Order status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + public Order complete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getComplete() { + return complete; + } + + + @JsonProperty(JSON_PROPERTY_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComplete(@javax.annotation.Nullable Boolean complete) { + this.complete = complete; + } + + + /** + * Return true if this Order object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `petId` to the URL query string + if (getPetId() != null) { + joiner.add(String.format("%spetId%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPetId())))); + } + + // add `quantity` to the URL query string + if (getQuantity() != null) { + joiner.add(String.format("%squantity%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getQuantity())))); + } + + // add `shipDate` to the URL query string + if (getShipDate() != null) { + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getShipDate())))); + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + // add `complete` to the URL query string + if (getComplete() != null) { + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getComplete())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Pet.java new file mode 100644 index 000000000000..fca9a3f7748c --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Pet.java @@ -0,0 +1,397 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A pet for sale in the pet store + */ +@JsonPropertyOrder({ + Pet.JSON_PROPERTY_ID, + Pet.JSON_PROPERTY_CATEGORY, + Pet.JSON_PROPERTY_NAME, + Pet.JSON_PROPERTY_PHOTO_URLS, + Pet.JSON_PROPERTY_TAGS, + Pet.JSON_PROPERTY_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Pet { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_CATEGORY = "category"; + @javax.annotation.Nullable + private Category category; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nonnull + private String name; + + public static final String JSON_PROPERTY_PHOTO_URLS = "photoUrls"; + @javax.annotation.Nonnull + private List photoUrls = new ArrayList<>(); + + public static final String JSON_PROPERTY_TAGS = "tags"; + @javax.annotation.Nullable + private List tags = new ArrayList<>(); + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE(String.valueOf("available")), + + PENDING(String.valueOf("pending")), + + SOLD(String.valueOf("sold")); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + @javax.annotation.Nullable + private StatusEnum status; + + public Pet() { + } + + public Pet id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Pet category(@javax.annotation.Nullable Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Category getCategory() { + return category; + } + + + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCategory(@javax.annotation.Nullable Category category) { + this.category = category; + } + + + public Pet name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public Pet photoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + if (this.photoUrls == null) { + this.photoUrls = new ArrayList<>(); + } + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getPhotoUrls() { + return photoUrls; + } + + + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setPhotoUrls(@javax.annotation.Nonnull List photoUrls) { + this.photoUrls = photoUrls; + } + + + public Pet tags(@javax.annotation.Nullable List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTags() { + return tags; + } + + + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTags(@javax.annotation.Nullable List tags) { + this.tags = tags; + } + + + public Pet status(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public StatusEnum getStatus() { + return status; + } + + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(@javax.annotation.Nullable StatusEnum status) { + this.status = status; + } + + + /** + * Return true if this Pet object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `category` to the URL query string + if (getCategory() != null) { + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + // add `photoUrls` to the URL query string + if (getPhotoUrls() != null) { + for (int i = 0; i < getPhotoUrls().size(); i++) { + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + ApiClient.urlEncode(ApiClient.valueToString(getPhotoUrls().get(i))))); + } + } + + // add `tags` to the URL query string + if (getTags() != null) { + for (int i = 0; i < getTags().size(); i++) { + if (getTags().get(i) != null) { + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Tag.java new file mode 100644 index 000000000000..c0d8663d423e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/Tag.java @@ -0,0 +1,187 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A tag for a pet + */ +@JsonPropertyOrder({ + Tag.JSON_PROPERTY_ID, + Tag.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class Tag { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + @javax.annotation.Nullable + private String name; + + public Tag() { + } + + public Tag id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public Tag name(@javax.annotation.Nullable 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(@javax.annotation.Nullable String name) { + this.name = name; + } + + + /** + * Return true if this Tag object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/User.java new file mode 100644 index 000000000000..c2694466621d --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/main/java/org/openapitools/client/model/User.java @@ -0,0 +1,403 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +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 java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * A User who is purchasing from the pet store + */ +@JsonPropertyOrder({ + User.JSON_PROPERTY_ID, + User.JSON_PROPERTY_USERNAME, + User.JSON_PROPERTY_FIRST_NAME, + User.JSON_PROPERTY_LAST_NAME, + User.JSON_PROPERTY_EMAIL, + User.JSON_PROPERTY_PASSWORD, + User.JSON_PROPERTY_PHONE, + User.JSON_PROPERTY_USER_STATUS +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-07-08T21:01:56.363494+07:00[Asia/Bangkok]", comments = "Generator version: 7.15.0-SNAPSHOT") +public class User { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nullable + private Long id; + + public static final String JSON_PROPERTY_USERNAME = "username"; + @javax.annotation.Nullable + private String username; + + public static final String JSON_PROPERTY_FIRST_NAME = "firstName"; + @javax.annotation.Nullable + private String firstName; + + public static final String JSON_PROPERTY_LAST_NAME = "lastName"; + @javax.annotation.Nullable + private String lastName; + + public static final String JSON_PROPERTY_EMAIL = "email"; + @javax.annotation.Nullable + private String email; + + public static final String JSON_PROPERTY_PASSWORD = "password"; + @javax.annotation.Nullable + private String password; + + public static final String JSON_PROPERTY_PHONE = "phone"; + @javax.annotation.Nullable + private String phone; + + public static final String JSON_PROPERTY_USER_STATUS = "userStatus"; + @javax.annotation.Nullable + private Integer userStatus; + + public User() { + } + + public User id(@javax.annotation.Nullable Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(@javax.annotation.Nullable Long id) { + this.id = id; + } + + + public User username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUsername() { + return username; + } + + + @JsonProperty(JSON_PROPERTY_USERNAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + + public User firstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstName() { + return firstName; + } + + + @JsonProperty(JSON_PROPERTY_FIRST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstName(@javax.annotation.Nullable String firstName) { + this.firstName = firstName; + } + + + public User lastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLastName() { + return lastName; + } + + + @JsonProperty(JSON_PROPERTY_LAST_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLastName(@javax.annotation.Nullable String lastName) { + this.lastName = lastName; + } + + + public User email(@javax.annotation.Nullable String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEmail() { + return email; + } + + + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEmail(@javax.annotation.Nullable String email) { + this.email = email; + } + + + public User password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPassword() { + return password; + } + + + @JsonProperty(JSON_PROPERTY_PASSWORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + + public User phone(@javax.annotation.Nullable String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPhone() { + return phone; + } + + + @JsonProperty(JSON_PROPERTY_PHONE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPhone(@javax.annotation.Nullable String phone) { + this.phone = phone; + } + + + public User userStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getUserStatus() { + return userStatus; + } + + + @JsonProperty(JSON_PROPERTY_USER_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUserStatus(@javax.annotation.Nullable Integer userStatus) { + this.userStatus = userStatus; + } + + + /** + * Return true if this User object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `username` to the URL query string + if (getUsername() != null) { + joiner.add(String.format("%susername%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUsername())))); + } + + // add `firstName` to the URL query string + if (getFirstName() != null) { + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getFirstName())))); + } + + // add `lastName` to the URL query string + if (getLastName() != null) { + joiner.add(String.format("%slastName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getLastName())))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add(String.format("%semail%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getEmail())))); + } + + // add `password` to the URL query string + if (getPassword() != null) { + joiner.add(String.format("%spassword%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPassword())))); + } + + // add `phone` to the URL query string + if (getPhone() != null) { + joiner.add(String.format("%sphone%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPhone())))); + } + + // add `userStatus` to the URL query string + if (getUserStatus() != null) { + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getUserStatus())))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/PetApiTest.java new file mode 100644 index 000000000000..f725ba246938 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -0,0 +1,180 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.io.File; +import org.openapitools.client.model.ModelApiResponse; +import org.openapitools.client.model.Pet; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for PetApi + */ +@Disabled +public class PetApiTest { + + private final PetApi api = new PetApi(); + + + /** + * Add a new pet to the store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void addPetTest() throws ApiException { + Pet pet = null; + Pet response = + api.addPet(pet); + + // TODO: test validations + } + + /** + * Deletes a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deletePetTest() throws ApiException { + Long petId = null; + String apiKey = null; + + api.deletePet(petId, apiKey); + + // TODO: test validations + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByStatusTest() throws ApiException { + List status = null; + List response = + api.findPetsByStatus(status); + + // TODO: test validations + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByTagsTest() throws ApiException { + List tags = null; + List response = + api.findPetsByTags(tags); + + // TODO: test validations + } + + /** + * Find pet by ID + * + * Returns a single pet + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getPetByIdTest() throws ApiException { + Long petId = null; + Pet response = + api.getPetById(petId); + + // TODO: test validations + } + + /** + * Update an existing pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetTest() throws ApiException { + Pet pet = null; + Pet response = + api.updatePet(pet); + + // TODO: test validations + } + + /** + * Updates a pet in the store with form data + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetWithFormTest() throws ApiException { + Long petId = null; + String name = null; + String status = null; + + api.updatePetWithForm(petId, name, status); + + // TODO: test validations + } + + /** + * uploads an image + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileTest() throws ApiException { + Long petId = null; + String additionalMetadata = null; + File _file = null; + ModelApiResponse response = + api.uploadFile(petId, additionalMetadata, _file); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/StoreApiTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/StoreApiTest.java new file mode 100644 index 000000000000..be318cab8b1e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/StoreApiTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import org.openapitools.client.model.Order; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for StoreApi + */ +@Disabled +public class StoreApiTest { + + private final StoreApi api = new StoreApi(); + + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteOrderTest() throws ApiException { + String orderId = null; + + api.deleteOrder(orderId); + + // TODO: test validations + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getInventoryTest() throws ApiException { + Map response = + api.getInventory(); + + // TODO: test validations + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getOrderByIdTest() throws ApiException { + Long orderId = null; + Order response = + api.getOrderById(orderId); + + // TODO: test validations + } + + /** + * Place an order for a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void placeOrderTest() throws ApiException { + Order order = null; + Order response = + api.placeOrder(order); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/UserApiTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/UserApiTest.java new file mode 100644 index 000000000000..2b2b7a60fd21 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/api/UserApiTest.java @@ -0,0 +1,175 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.api; + +import org.openapitools.client.ApiException; +import java.time.OffsetDateTime; +import org.openapitools.client.model.User; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for UserApi + */ +@Disabled +public class UserApiTest { + + private final UserApi api = new UserApi(); + + + /** + * Create user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUserTest() throws ApiException { + User user = null; + + api.createUser(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() throws ApiException { + List user = null; + + api.createUsersWithArrayInput(user); + + // TODO: test validations + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() throws ApiException { + List user = null; + + api.createUsersWithListInput(user); + + // TODO: test validations + } + + /** + * Delete user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteUserTest() throws ApiException { + String username = null; + + api.deleteUser(username); + + // TODO: test validations + } + + /** + * Get user by user name + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserByNameTest() throws ApiException { + String username = null; + User response = + api.getUserByName(username); + + // TODO: test validations + } + + /** + * Logs user into the system + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void loginUserTest() throws ApiException { + String username = null; + String password = null; + String response = + api.loginUser(username, password); + + // TODO: test validations + } + + /** + * Logs out current logged in user session + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void logoutUserTest() throws ApiException { + + api.logoutUser(); + + // TODO: test validations + } + + /** + * Updated user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserTest() throws ApiException { + String username = null; + User user = null; + + api.updateUser(username, user); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/CategoryTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/CategoryTest.java new file mode 100644 index 000000000000..ae23ab433a50 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/CategoryTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Category + */ +class CategoryTest { + private final Category model = new Category(); + + /** + * Model tests for Category + */ + @Test + void testCategory() { + // TODO: test Category + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java new file mode 100644 index 000000000000..c846563bfe1f --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/ModelApiResponseTest.java @@ -0,0 +1,64 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ModelApiResponse + */ +class ModelApiResponseTest { + private final ModelApiResponse model = new ModelApiResponse(); + + /** + * Model tests for ModelApiResponse + */ + @Test + void testModelApiResponse() { + // TODO: test ModelApiResponse + } + + /** + * Test the property 'code' + */ + @Test + void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + void messageTest() { + // TODO: test message + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/OrderTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/OrderTest.java new file mode 100644 index 000000000000..4d8d136809eb --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/OrderTest.java @@ -0,0 +1,89 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Order + */ +class OrderTest { + private final Order model = new Order(); + + /** + * Model tests for Order + */ + @Test + void testOrder() { + // TODO: test Order + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'petId' + */ + @Test + void petIdTest() { + // TODO: test petId + } + + /** + * Test the property 'quantity' + */ + @Test + void quantityTest() { + // TODO: test quantity + } + + /** + * Test the property 'shipDate' + */ + @Test + void shipDateTest() { + // TODO: test shipDate + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + + /** + * Test the property 'complete' + */ + @Test + void completeTest() { + // TODO: test complete + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/PetTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/PetTest.java new file mode 100644 index 000000000000..84aff8adbf96 --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/PetTest.java @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Pet + */ +class PetTest { + private final Pet model = new Pet(); + + /** + * Model tests for Pet + */ + @Test + void testPet() { + // TODO: test Pet + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'category' + */ + @Test + void categoryTest() { + // TODO: test category + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'photoUrls' + */ + @Test + void photoUrlsTest() { + // TODO: test photoUrls + } + + /** + * Test the property 'tags' + */ + @Test + void tagsTest() { + // TODO: test tags + } + + /** + * Test the property 'status' + */ + @Test + void statusTest() { + // TODO: test status + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/TagTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/TagTest.java new file mode 100644 index 000000000000..6bd8b9f5035e --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/TagTest.java @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for Tag + */ +class TagTest { + private final Tag model = new Tag(); + + /** + * Model tests for Tag + */ + @Test + void testTag() { + // TODO: test Tag + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/UserTest.java b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/UserTest.java new file mode 100644 index 000000000000..40f4892264aa --- /dev/null +++ b/samples/client/petstore/java/native/test-regenerated/src/test/java/org/openapitools/client/model/UserTest.java @@ -0,0 +1,104 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for User + */ +class UserTest { + private final User model = new User(); + + /** + * Model tests for User + */ + @Test + void testUser() { + // TODO: test User + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'username' + */ + @Test + void usernameTest() { + // TODO: test username + } + + /** + * Test the property 'firstName' + */ + @Test + void firstNameTest() { + // TODO: test firstName + } + + /** + * Test the property 'lastName' + */ + @Test + void lastNameTest() { + // TODO: test lastName + } + + /** + * Test the property 'email' + */ + @Test + void emailTest() { + // TODO: test email + } + + /** + * Test the property 'password' + */ + @Test + void passwordTest() { + // TODO: test password + } + + /** + * Test the property 'phone' + */ + @Test + void phoneTest() { + // TODO: test phone + } + + /** + * Test the property 'userStatus' + */ + @Test + void userStatusTest() { + // TODO: test userStatus + } + +}