Skip to content

[BUG][JAVA][Feign]: erroneous Param-mapping causes "Body parameters cannot be used with form parameters" #5249

@Chr1st0ph

Description

@Chr1st0ph

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Generating a Feign-client with header-param, e.g. Authorization, causes a validation-error:

Caused by: java.lang.IllegalStateException: Body parameters cannot be used with form parameters.
at feign.Util.checkState(Util.java:130) ~[feign-core-10.4.0.jar:na]

openapi-generator version

4.2.3

OpenAPI declaration file content or url

https://gist.github.com/Chr1st0ph/bb10430c703f79dd938201c19c92fbc1

Generated code:

  @RequestLine("POST /examples")
  @Headers({
    "Content-Type: application/json",
    "Accept: application/json",
    "Authorization: {authorization}"
  })
  void postExample(@Param("Authorization") String authorization, String body);

Mapping in Headers-annotation for Authorization does not fit to mapping in Param-annotation.

Command line used for generation

mvn spring-boot:run -Dspring-boot

Steps to reproduce

Create files ( see linked GIST ), and run the Maven-command.

Related issues/PRs

I did a swift search, but did not find an open issue for it.

Suggest a fix

I will provide a merge-request for using paramName instead of baseName in openapi-generator/modules/openapi-generator/src/main/resources/Java/libraries/feign/api.mustache

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions