Giter Site home page Giter Site logo

brunoalbrito / jetty-maven-cdi-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rmohr/jetty-maven-cdi-demo

0.0 0.0 0.0 156 KB

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

License: Apache License 2.0

Java 100.00%

jetty-maven-cdi-demo's Introduction

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.

jetty-maven-cdi-demo's People

Contributors

rmohr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.