Skip to content

Commit

Permalink
[Java][Feign] Bug fix in @param annotation (OpenAPITools#5250)
Browse files Browse the repository at this point in the history
* FIX-5249 fix @param annotation for Feign-client code generation

Use paramName instead of baseName in order to make mapping in @headers
section fit the param-value.

* update samples

* FIX-5249 fix @param annotation for Feign-client code generation

Use paramName instead of baseName in order to make mapping in @headers
section fit the param-value.

Co-authored-by: Christoph Preißner <christoph.preissner@blu-pa.com>
Co-authored-by: William Cheng <wing328hk@gmail.com>
  • Loading branch information
3 people authored and MikailBag committed May 31, 2020
1 parent 49f0eb9 commit 980c07d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface {{classname}} extends ApiClient.Api {
"{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
{{/hasMore}}{{/headerParams}}
})
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isBodyParam}}{{^legacyDates}}@Param("{{baseName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{baseName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{baseName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{#hasQueryParams}}

/**
Expand Down Expand Up @@ -80,7 +80,7 @@ public interface {{classname}} extends ApiClient.Api {
"{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
{{/hasMore}}{{/headerParams}}
})
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^legacyDates}}@Param("{{baseName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{baseName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map<String, Object> queryParams);
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{baseName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map<String, Object> queryParams);

/**
* A convenience class for generating query parameters for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json",
})
void testEndpointParameters(@Param("number") BigDecimal number, @Param("double") Double _double, @Param("pattern_without_delimiter") String patternWithoutDelimiter, @Param("byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("callback") String paramCallback);
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback);

/**
* To test enum parameters
Expand All @@ -203,7 +203,7 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {

"enum_header_string: {enumHeaderString}"
})
void testEnumParameters(@Param("enum_header_string_array") List<String> enumHeaderStringArray, @Param("enum_header_string") String enumHeaderString, @Param("enum_query_string_array") List<String> enumQueryStringArray, @Param("enum_query_string") String enumQueryString, @Param("enum_query_integer") Integer enumQueryInteger, @Param("enum_query_double") Double enumQueryDouble, @Param("enum_form_string_array") List<String> enumFormStringArray, @Param("enum_form_string") String enumFormString);
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString);

/**
* To test enum parameters
Expand Down Expand Up @@ -234,7 +234,7 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {

"enum_header_string: {enumHeaderString}"
})
void testEnumParameters(@Param("enum_header_string_array") List<String> enumHeaderStringArray, @Param("enum_header_string") String enumHeaderString, @Param("enum_form_string_array") List<String> enumFormStringArray, @Param("enum_form_string") String enumFormString, @QueryMap(encoded=true) Map<String, Object> queryParams);
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString, @QueryMap(encoded=true) Map<String, Object> queryParams);

/**
* A convenience class for generating query parameters for the
Expand Down Expand Up @@ -276,7 +276,7 @@ public TestEnumParametersQueryParams enumQueryDouble(final Double value) {

"boolean_group: {booleanGroup}"
})
void testGroupParameters(@Param("required_string_group") Integer requiredStringGroup, @Param("required_boolean_group") Boolean requiredBooleanGroup, @Param("required_int64_group") Long requiredInt64Group, @Param("string_group") Integer stringGroup, @Param("boolean_group") Boolean booleanGroup, @Param("int64_group") Long int64Group);
void testGroupParameters(@Param("requiredStringGroup") Integer requiredStringGroup, @Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("requiredInt64Group") Long requiredInt64Group, @Param("stringGroup") Integer stringGroup, @Param("booleanGroup") Boolean booleanGroup, @Param("int64Group") Long int64Group);

/**
* Fake endpoint to test group parameters (optional)
Expand Down Expand Up @@ -304,7 +304,7 @@ public TestEnumParametersQueryParams enumQueryDouble(final Double value) {

"boolean_group: {booleanGroup}"
})
void testGroupParameters(@Param("required_boolean_group") Boolean requiredBooleanGroup, @Param("boolean_group") Boolean booleanGroup, @QueryMap(encoded=true) Map<String, Object> queryParams);
void testGroupParameters(@Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("booleanGroup") Boolean booleanGroup, @QueryMap(encoded=true) Map<String, Object> queryParams);

/**
* A convenience class for generating query parameters for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface PetApi extends ApiClient.Api {
"Accept: application/json",
"api_key: {apiKey}"
})
void deletePet(@Param("petId") Long petId, @Param("api_key") String apiKey);
void deletePet(@Param("petId") Long petId, @Param("apiKey") String apiKey);

/**
* Finds Pets by status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface StoreApi extends ApiClient.Api {
@Headers({
"Accept: application/json",
})
void deleteOrder(@Param("order_id") String orderId);
void deleteOrder(@Param("orderId") String orderId);

/**
* Returns pet inventories by status
Expand All @@ -47,7 +47,7 @@ public interface StoreApi extends ApiClient.Api {
@Headers({
"Accept: application/json",
})
Order getOrderById(@Param("order_id") Long orderId);
Order getOrderById(@Param("orderId") Long orderId);

/**
* Place an order for a pet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json",
})
void testEndpointParameters(@Param("number") BigDecimal number, @Param("double") Double _double, @Param("pattern_without_delimiter") String patternWithoutDelimiter, @Param("byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("callback") String paramCallback);
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback);

/**
* To test enum parameters
Expand All @@ -203,7 +203,7 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {

"enum_header_string: {enumHeaderString}"
})
void testEnumParameters(@Param("enum_header_string_array") List<String> enumHeaderStringArray, @Param("enum_header_string") String enumHeaderString, @Param("enum_query_string_array") List<String> enumQueryStringArray, @Param("enum_query_string") String enumQueryString, @Param("enum_query_integer") Integer enumQueryInteger, @Param("enum_query_double") Double enumQueryDouble, @Param("enum_form_string_array") List<String> enumFormStringArray, @Param("enum_form_string") String enumFormString);
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString);

/**
* To test enum parameters
Expand Down Expand Up @@ -234,7 +234,7 @@ public TestBodyWithQueryParamsQueryParams query(final String value) {

"enum_header_string: {enumHeaderString}"
})
void testEnumParameters(@Param("enum_header_string_array") List<String> enumHeaderStringArray, @Param("enum_header_string") String enumHeaderString, @Param("enum_form_string_array") List<String> enumFormStringArray, @Param("enum_form_string") String enumFormString, @QueryMap(encoded=true) Map<String, Object> queryParams);
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString, @QueryMap(encoded=true) Map<String, Object> queryParams);

/**
* A convenience class for generating query parameters for the
Expand Down Expand Up @@ -276,7 +276,7 @@ public TestEnumParametersQueryParams enumQueryDouble(final Double value) {

"boolean_group: {booleanGroup}"
})
void testGroupParameters(@Param("required_string_group") Integer requiredStringGroup, @Param("required_boolean_group") Boolean requiredBooleanGroup, @Param("required_int64_group") Long requiredInt64Group, @Param("string_group") Integer stringGroup, @Param("boolean_group") Boolean booleanGroup, @Param("int64_group") Long int64Group);
void testGroupParameters(@Param("requiredStringGroup") Integer requiredStringGroup, @Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("requiredInt64Group") Long requiredInt64Group, @Param("stringGroup") Integer stringGroup, @Param("booleanGroup") Boolean booleanGroup, @Param("int64Group") Long int64Group);

/**
* Fake endpoint to test group parameters (optional)
Expand Down Expand Up @@ -304,7 +304,7 @@ public TestEnumParametersQueryParams enumQueryDouble(final Double value) {

"boolean_group: {booleanGroup}"
})
void testGroupParameters(@Param("required_boolean_group") Boolean requiredBooleanGroup, @Param("boolean_group") Boolean booleanGroup, @QueryMap(encoded=true) Map<String, Object> queryParams);
void testGroupParameters(@Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("booleanGroup") Boolean booleanGroup, @QueryMap(encoded=true) Map<String, Object> queryParams);

/**
* A convenience class for generating query parameters for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface PetApi extends ApiClient.Api {
"Accept: application/json",
"api_key: {apiKey}"
})
void deletePet(@Param("petId") Long petId, @Param("api_key") String apiKey);
void deletePet(@Param("petId") Long petId, @Param("apiKey") String apiKey);

/**
* Finds Pets by status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface StoreApi extends ApiClient.Api {
@Headers({
"Accept: application/json",
})
void deleteOrder(@Param("order_id") String orderId);
void deleteOrder(@Param("orderId") String orderId);

/**
* Returns pet inventories by status
Expand All @@ -47,7 +47,7 @@ public interface StoreApi extends ApiClient.Api {
@Headers({
"Accept: application/json",
})
Order getOrderById(@Param("order_id") Long orderId);
Order getOrderById(@Param("orderId") Long orderId);

/**
* Place an order for a pet
Expand Down

0 comments on commit 980c07d

Please sign in to comment.