Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rmohr/jetty-maven-cdi-demo

Demo application on how to setup and use resteasy, swagger, weld, jsr-303 and jetty together
https://github.com/rmohr/jetty-maven-cdi-demo

Last synced: 14 days ago
JSON representation

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

Awesome Lists containing this project

README

        

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
or
. 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](../master/src/main/java/rmohr/examples/cdi/RestScanner.java).

Visit multiple times to see the Greeter service in
action, which is injected in the root resource.

Visit 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.