question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for encoders even when no or multiple body parameters are present

See original GitHub issue

Currently Feign will not resolve methods with BuildEncodedTemplateFromArgs if they have 0 or more than 1 body parameters, which prevents the usage of custom Feign encoders. There are use cases though where an application (or library) needs a client with a custom encoder and needs that encoder triggered even if the client method has 0 or more than 1 “body parameters” (parameters not annotated with Feign annotations or custom annotations registered in Feign using DeclarativeContract.registerParameterAnnotation).

A few examples of this use case:

  1. An application needs a Feign client whose request payload is defined entirely by a custom Feign encoder even if no parameter is declared at the client method. In this case, even with no presence of body parameter the encoder will know how to define the request payload (based on the method name, method return type, and other optional metadata provided by annotations).
  2. An application needs a Feign client whose request payload is defined by a custom Feign encoder plus one or more parameters, all of them annotated with custom annotation(s) registered in Feign using DeclarativeContract.registerParameterAnnotation. In this case the encoder will use all the parameters, plus metadata in their respective annotations, to properly define the request message payload.

To be more specific, this issue is required to support certain use cases in Mocca. This improvement would help to simplify Mocca’s API a lot.

We are also open to contributing a PR to implement this feature, if Feign team first accesses this issue and let us know we should do so.

By the way, we tried first to address this use case by creating a custom Feign Contract implementation, but that was not possible because overwriting a parseAndValidateMetadata requires instantiating MethodMetadata and that class has a package-private constructor (besides being final too).

Please let us know your thoughts on this and, if you believe this is an useful enhancement to have, if we can go ahead and provide a PR addressing this (or if you prefer to do so yourselves, please let us know the timeline to provide it).

Thanks.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:39 (39 by maintainers)

github_iconTop GitHub Comments

1reaction
kdavisk6commented, Jun 30, 2021

@fabiocarvalho777 Looks like we work together. Look me up at work and we can chat.

0reactions
fabiocarvalho777commented, Jul 13, 2021

@velo @kdavisk6 here is the PR #1459.

Please just let me know if you have any requests for changes, or if this PR should be opened against a different branch and I will do it. Thank you very much.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Encoder error while trying to map dataframe row to updated row
You're trying to use code which has been written with Spark 1.x and is no longer supported in Spark 2.0: in 1.x DataFrame.map...
Read more >
Body - Multiple Parameters - FastAPI
You can add multiple body parameters to your path operation function, even though a request can only have a single body. But FastAPI...
Read more >
How to use character encoding classes in .NET - Microsoft Learn
Single glyphs rendered on a display can still be encoded with more than one UTF-32 character. ANSI/ISO encoding, Provides support for a variety ......
Read more >
Web on Reactive Stack - Spring
The reactive-stack web framework, Spring WebFlux, was added later in ... If you have a Spring MVC application that works fine, there is...
Read more >
Pixel Streaming Reference - Unreal Engine Documentation
Other browsers such as Microsoft Edge and Opera may require add-ons or plugins, and may not work on all systems. Supported Encoders. Encoder....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found