Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Swagger Integration

Holger Staudacher edited this page Nov 12, 2015 · 1 revision

The OSGi-JAX-RS Connector provides swagger integration in a separate bundle called com.eclipsesource.jaxrsprovider.swagger. This bundle just needs to be started in the same OSGi instance your JAX-RS reosurces run in and swagger is ready to serve.

Dependencies

The com.eclipsesource.jaxrsprovider.swagger depends on Swagger. Swagger itself has a lot of dependencies which makes it no fun when you have to manage the dependencies manually. For this reason the OSGi-JAX-RS connector project provides a rebundled version of Swagger that is self contained called com.eclipsesource.jaxrs.swagger-all. Please note: The provider bundle only uses package imports. So, it's up to you to use the all bundle or the original Swagger artifacts.

Usage

Swagger registers a resource on the path /swagger.json and /swagger.yaml. Please note the this registration is relative to your configured root path. So, if you are using /services as the root path your swagger.json will be available on /services/swagger.json. See the swagger.io website and documentation for more information about Swagger.

Configuration

The Swagger integration provides the ability to configure Swagger using the OSGi configuration admin. You can configure the service with pid com.eclipsesource.jaxrs.swagger.config using the following properties:

swagger.basePath
swagger.host
swagger.filterClass
swagger.info.title
swagger.info.description
swagger.info.version
swagger.info.termsOfService
swagger.info.contact.name
swagger.info.contact.url
swagger.info.contact.email
swagger.info.license.name
swagger.info.license.url

Please see the Swagger specification for the meaning of these properties.

Example

An example is located in examples/com.eclipsesource.jaxrs.connector.example.swagger which registers just one service and uses the OSGi config admin to configure swagger. The image below shows the example used together with Swagger UI. swagger ui

Clone this wiki locally