Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
com.github.mwiede:feign-validation
Advanced tools
A decorator wrapping Feign client method handlers in order to provide validation on response object.
A library for Feign containing a decorator which makes it possible to validate reponses using bean validation api 1.1 (JSR 349) or bean validation 2.0 (JSR 380).
While Jersey as the JAX-RS implementation provides Bean Validation Support, Feign acts as a client and til now only supports a limited set of annotations
in it's JAX-RS module, meaning @javax.validation.Valid
or @javax.validation.groups.ConvertGroup
are not supported.
This library contains a decorator class, which can be setup within invocationHandlerFactory to retrieve additional validation.
Sometimes it is required, that a client also validates the response it got from the providing service/endpoint. With JSR-349 bean validation, Java provides a nice api for validation purposes. Just by adding annotations like @NotNull
or @Email
, contraints can be validated very easily.
With JSR-380 you even get support for new date/time data types (JSR 310) and more.
feign-validation Version | JSR | Validation Api Version |
---|---|---|
1.x | JSR-349 support | javax.validation:validation-api:1.1.0.Final |
2.x and beyond | JSR-380 support | javax.validation:validation-api:2.0.1.Final |
Here is how you can activate bean validation within Feign wrapper client:
interface GitHub {
@RequestLine("GET /repos/{owner}/{repo}/contributors")
@Size(min = 1)
@Valid
List<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo);
}
static class Contributor {
@NotNull
@Size(min = 10)
String login;
int contributions;
}
public static void main(String... args) {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
GitHub github = ExtendedFeign.builder(validator)//
.decoder(new GsonDecoder()).target(GitHub.class, "https://api.github.com");
// Fetch and print a list of the contributors to this library.
try {
List<Contributor> contributors = github.contributors("OpenFeign", "feign");
for (Contributor contributor : contributors) {
System.out.println(contributor.login + " (" + contributor.contributions + ")");
}
} catch (ConstraintViolationException ex) {
ex.getConstraintViolations().forEach(System.out::println);
}
}
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>feign-validation</artifactId>
<version>1.0</version>
</dependency>
FAQs
A decorator wrapping Feign client method handlers in order to provide validation on response object.
We found that com.github.mwiede:feign-validation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.