Comments (5)
We are investigating whether this is caused by #15.
from serverless-java-container.
I have an update on filters posted on #15
from serverless-java-container.
@AlainJanssens can you paste here some sample code on how you use @Valid
(both init and runtime) so that I can include it in a unit test?
from serverless-java-container.
Turns out this is not caused by #15. I have looked into this and managed to get the @Valid
annotation working. I've added a unit test for this in the new branch
Few things to do:
- declare your config as an
AnnotationConfigWebApplicationContext
:
@Configuration
@ComponentScan("com.amazonaws.serverless.proxy.spring.echoapp")
public class EchoSpringAppConfig {
@Autowired
private AnnotationConfigWebApplicationContext applicationContext;
@Bean
public SpringLambdaContainerHandler springLambdaContainerHandler() throws ContainerInitializationException {
SpringLambdaContainerHandler handler = SpringLambdaContainerHandler.getAwsProxyHandler(applicationContext);
handler.setRefreshContext(false);
return handler;
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
@Bean
public MockLambdaContext lambdaContext() {
return new MockLambdaContext();
}
@Bean
public javax.validation.Validator localValidatorFactoryBean() {
return new LocalValidatorFactoryBean();
}
}
- Add the required dependencies in the pom.xml file:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.4</version>
</dependency>
- Use the
@Valid
annotation in your method.
@RequestMapping(path = "/user", method=RequestMethod.POST, consumes = MediaType.APPLICATION_JSON)
public ResponseEntity<ValidatedUserModel> createUser(@Valid @RequestBody ValidatedUserModel newUser, BindingResult results) {
...
from serverless-java-container.
Switched to help wanted tag and closing the issue.
from serverless-java-container.
Related Issues (20)
- Spring Async initialization still initializing twice, timing out, wrong docs/sample HOT 4
- SpringBoot3 with JPA dependency fails to handle asynchronous requests. HOT 3
- SpringBoot3 not processing all Multipart files when Array of files with same fieldName is sent in request HOT 3
- feature: Support VPC Lattice integration as frontend service HOT 1
- Provide concrete example of building custom events HOT 1
- How can I get 'apigateway authorizer' context content in SpringBoot2? HOT 1
- Incorrect ServerName with ALB HOT 1
- Stable v2 release date HOT 8
- Spring throwExceptionIfNoHandlerFound is true by default as of Spring 6.1.x
- HTTP API is supported? HOT 2
- Spring for GraphQL support/ sample HOT 2
- "java.lang.NoClassDefFoundError" on Pet Store sample project HOT 3
- SpringDelegatingLambdaContainerHandler seems does not work with query parameters HOT 8
- SpringDelegatingLambdaContainerHandler should reuse AsyncInitializationWrapper HOT 5
- Not able to apply spring security on pet-store-native sample HOT 6
- No public method named handleRequest with appropriate method signature on SpringBootLambdaContainerHandler HOT 12
- `IAM` authorizer is discarded HOT 2
- Not getting reponse back directly from filter HOT 1
- Reinitialization of Spring context when using SnapStart HOT 3
- Spring Cloud Gateway throwing "hostname can't be null" based on my request only having headers and not multi-value headers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-java-container.