Giter Club home page Giter Club logo

jakarta-jersey-jetty-swagger-example's Introduction

Minimum example of REST API using Jersey in Jakarta Namespace with Swagger Docs

As most of the examples online don't utilize jakarta instead of javax namespace, I put together an example that puts these libraries together using the new jakarta namespace and JDK17.

Build/Usage

Project is built with Java 17 SDK using Maven.

To compile: mvn clean compile

To run: mvn clean compile exec:java

The exec-maven-plugin takes care of calling the correct main class.

Where do I find what?

The used port of the interface is set in example.MainApplication. In this case it is 8888.

  • WADL is located at http://localhost:8888/application.wadl and should tell you about all remaining resources
  • API is then located at http://localhost:8888/example, to quickly test it open http://localhost:8888/example/result in the browser.
  • OpenAPI docs are located at http://localhost:8888/openapi.json
  • Swagger UI is located at http://localhost:8888/ui/, per default opening the openapi.json configured in /src/main/resources/webapp/ui/swagger-initializer.js

Setup hints

  • The version of most packages are set in the <properties> in the beginning of the POM file
  • When changing package names (or adding additional packages), make sure to update usages like in MainApplication in the init parameters of the ServletHolder as well
  • Swagger offers separate artifacts for jakarta and javax namespaces, make sure to use the correct ones throughout

Sources

This Example was built by putting together code from multiple examples and documentation (list may be incomplete):

Official Jersey documentation and examples:

Swagger documentation:

Setting up Swagger as Jetty Servlet:

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.