Skip to content

Demo application on how to setup and use resteasy, swagger, weld, jsr-303 and jetty together

License

Notifications You must be signed in to change notification settings

rmohr/jetty-maven-cdi-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jetty-maven-cdi demo

This small demo describes how to configure a project to get the following features:

  • Dependency injection in jetty through weld
  • Automatic resteasy resource scanning and dependency injection through weld
  • JSR-303 validation in resteasy resources
  • Swagger jax-rs scanning
  • Swagger serving the rest documentation on an endpoint
  • JAX-RS subresource handling with resteasy and swagger

To run the application simply type

$ mvn jetty:run

When the application is started, you can look up the swagger documentation on http://localhost:8080/api-docs/swagger.json or http://localhost:8080/api-docs/swagger.yaml. The most difficult part here is to convince swagger to scan your resteasy resources. The documentation is not that good on that part. You can find the scanner which is also the servlet which provides the documentation here.

Visit http://localhost:8080/api multiple times to see the Greeter service in action, which is injected in the root resource.

Visit http://localhost:8080/api/sub to see the injected Greeter service invoked from the subresource.

Run

$ curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST \
  -i -d '{"name":"test", "description":"testsettsddsfs", "tags":["a", "b"]}' \
  http://localhost:8080/api/sub/dto

to post a valid dto and run

$ curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST \
  -i -d '{"name":"test", "description":"", "tags":["a", "b"]}' \
  http://localhost:8080/api/sub/dto

to post an invalid dto, to see the JSR-303 validation in action.

About

Demo application on how to setup and use resteasy, swagger, weld, jsr-303 and jetty together

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages