From 36287acfd61c0435832cc783b18ce07e2c0a8f93 Mon Sep 17 00:00:00 2001 From: Greg Knox Date: Mon, 31 Mar 2025 00:37:06 +1000 Subject: [PATCH] [JAVA][BUG] formParams.mustache should contain @FormParam, not @QueryParam (#20991) (#20993) * formParams.mustache should contain @FormParam, not @QueryParam (#20991) * updated samples; form parameters are declared using @FormParam, not @QueryParam (#20991) --- .../JavaJaxRS/libraries/jersey3/formParams.mustache | 2 +- .../jersey3/src/gen/java/org/openapitools/api/FakeApi.java | 6 +++--- .../jersey3/src/gen/java/org/openapitools/api/PetApi.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/libraries/jersey3/formParams.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/libraries/jersey3/formParams.mustache index 804fc69d930..939e3469e23 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/libraries/jersey3/formParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/libraries/jersey3/formParams.mustache @@ -13,7 +13,7 @@ }}{{^vendorExtensions.x-multipart}}{{! }}{{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}}{{! - }} @QueryParam("{{baseName}}"){{! + }} @FormParam("{{baseName}}"){{! }} {{{dataType}}} {{paramName}}{{! }}{{/vendorExtensions.x-multipart}}{{! diff --git a/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/FakeApi.java index 917ce943a94..a285a207cfa 100644 --- a/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/FakeApi.java @@ -248,7 +248,7 @@ public class FakeApi { },security = { @SecurityRequirement(name = "http_basic_test") }, tags={ "fake", }) - public Response testEndpointParameters(@Schema(description = "None") @QueryParam("number") BigDecimal number,@Schema(description = "None") @QueryParam("double") Double _double,@Schema(description = "None") @QueryParam("pattern_without_delimiter") String patternWithoutDelimiter,@Schema(description = "None") @QueryParam("byte") byte[] _byte,@Schema(description = "None") @QueryParam("integer") Integer integer,@Schema(description = "None") @QueryParam("int32") Integer int32,@Schema(description = "None") @QueryParam("int64") Long int64,@Schema(description = "None") @QueryParam("float") Float _float,@Schema(description = "None") @QueryParam("string") String string,@FormDataParam("binary") FormDataBodyPart binaryBodypart,@Schema(description = "None") @QueryParam("date") Date date,@Schema(description = "None") @QueryParam("dateTime") Date dateTime,@Schema(description = "None") @QueryParam("password") String password,@Schema(description = "None") @QueryParam("callback") String paramCallback,@Context SecurityContext securityContext) + public Response testEndpointParameters(@Schema(description = "None") @FormParam("number") BigDecimal number,@Schema(description = "None") @FormParam("double") Double _double,@Schema(description = "None") @FormParam("pattern_without_delimiter") String patternWithoutDelimiter,@Schema(description = "None") @FormParam("byte") byte[] _byte,@Schema(description = "None") @FormParam("integer") Integer integer,@Schema(description = "None") @FormParam("int32") Integer int32,@Schema(description = "None") @FormParam("int64") Long int64,@Schema(description = "None") @FormParam("float") Float _float,@Schema(description = "None") @FormParam("string") String string,@FormDataParam("binary") FormDataBodyPart binaryBodypart,@Schema(description = "None") @FormParam("date") Date date,@Schema(description = "None") @FormParam("dateTime") Date dateTime,@Schema(description = "None") @FormParam("password") String password,@Schema(description = "None") @FormParam("callback") String paramCallback,@Context SecurityContext securityContext) throws NotFoundException { return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binaryBodypart, date, dateTime, password, paramCallback, securityContext); } @@ -261,7 +261,7 @@ public class FakeApi { @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = Void.class))), }, tags={ "fake", }) - public Response testEnumParameters(@Schema(description = "Header parameter enum test (string array)" , allowableValues=">, $")@HeaderParam("enum_header_string_array") List enumHeaderStringArray,@Schema(description = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg")@HeaderParam("enum_header_string") String enumHeaderString,@Schema(description = "Query parameter enum test (string array)") @QueryParam("enum_query_string_array") List enumQueryStringArray,@Schema(description = "Query parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue = "-efg") @DefaultValue("-efg") @QueryParam("enum_query_string") String enumQueryString,@Schema(description = "Query parameter enum test (double)", allowableValues="1, -2") @QueryParam("enum_query_integer") Integer enumQueryInteger,@Schema(description = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @QueryParam("enum_query_double") Double enumQueryDouble,@Schema(description = "") @QueryParam("enum_query_model_array") List enumQueryModelArray,@Schema(description = "Form parameter enum test (string array)", allowableValues=">, $", defaultValue="$") @DefaultValue("$") @QueryParam("enum_form_string_array") List enumFormStringArray,@Schema(description = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @DefaultValue("-efg") @QueryParam("enum_form_string") String enumFormString,@Context SecurityContext securityContext) + public Response testEnumParameters(@Schema(description = "Header parameter enum test (string array)" , allowableValues=">, $")@HeaderParam("enum_header_string_array") List enumHeaderStringArray,@Schema(description = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg")@HeaderParam("enum_header_string") String enumHeaderString,@Schema(description = "Query parameter enum test (string array)") @QueryParam("enum_query_string_array") List enumQueryStringArray,@Schema(description = "Query parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue = "-efg") @DefaultValue("-efg") @QueryParam("enum_query_string") String enumQueryString,@Schema(description = "Query parameter enum test (double)", allowableValues="1, -2") @QueryParam("enum_query_integer") Integer enumQueryInteger,@Schema(description = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @QueryParam("enum_query_double") Double enumQueryDouble,@Schema(description = "") @QueryParam("enum_query_model_array") List enumQueryModelArray,@Schema(description = "Form parameter enum test (string array)", allowableValues=">, $", defaultValue="$") @DefaultValue("$") @FormParam("enum_form_string_array") List enumFormStringArray,@Schema(description = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @DefaultValue("-efg") @FormParam("enum_form_string") String enumFormString,@Context SecurityContext securityContext) throws NotFoundException { return delegate.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString, securityContext); } @@ -309,7 +309,7 @@ public class FakeApi { @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Void.class))), }, tags={ "fake", }) - public Response testJsonFormData(@Schema(description = "field1") @QueryParam("param") String param,@Schema(description = "field2") @QueryParam("param2") String param2,@Context SecurityContext securityContext) + public Response testJsonFormData(@Schema(description = "field1") @FormParam("param") String param,@Schema(description = "field2") @FormParam("param2") String param2,@Context SecurityContext securityContext) throws NotFoundException { return delegate.testJsonFormData(param, param2, securityContext); } diff --git a/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/PetApi.java index 62be4e39fab..2b0b240921b 100644 --- a/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/jaxrs/jersey3/src/gen/java/org/openapitools/api/PetApi.java @@ -173,7 +173,7 @@ public class PetApi { },security = { @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) }, tags={ "pet", }) - public Response updatePetWithForm(@Schema(description= "ID of pet that needs to be updated", required = true) @PathParam("petId") @NotNull Long petId,@Schema(description = "Updated name of the pet") @QueryParam("name") String name,@Schema(description = "Updated status of the pet") @QueryParam("status") String status,@Context SecurityContext securityContext) + public Response updatePetWithForm(@Schema(description= "ID of pet that needs to be updated", required = true) @PathParam("petId") @NotNull Long petId,@Schema(description = "Updated name of the pet") @FormParam("name") String name,@Schema(description = "Updated status of the pet") @FormParam("status") String status,@Context SecurityContext securityContext) throws NotFoundException { return delegate.updatePetWithForm(petId, name, status, securityContext); }