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

Use spring-boot properties to create SpringFox Dockets

License

Notifications You must be signed in to change notification settings

toolisticon/springboot-swagger-starter

Repository files navigation

Springboot Swagger Starter

unmaintained Build Status Maven Central codecov

Springboot Swagger Starter allows to create SpringFox Dockets using Springboot. We make use of SpringFox library, but ban the boilerplate code needed for creation of a Docklet. So instead of providing a @Bean that returns your Docket, you can just specify it using your properties or YAML file.

Installation and requirements

Minimal tested versions:

  • Spring-Boot 2.3.1.RELEASE
  • SpringFox Swagger 3.0.0

Put the following dependency to your Maven POM file:

<dependency>
  <groupId>io.toolisticon.springboot</groupId>
  <artifactId>springboot-swagger-starter</artifactId>
  <version>0.3.0</version>
</dependency>

resp.:

implementation("io.toolisticon.springboot:springboot-swagger-starter:0.3.0")

In your application.yml add the following block:

swagger:
  enabled: true
  redirect: true
  apiInfo:
    title: The Muppet Show API
    description: Use this to get a greeting from Muppet Show.
    version: 1.0
    termsOfService: use on your own risk
    lisense: APACHE-2.0
    licenseUrl: LICENSE.txt
    contact:
      name: Miss Piggy
      email: [email protected]
      url: http://muppetshow.biz      
  dockets:
    muppetShow:
      basePackage: "biz.muppetshow.rest"
      path: "/show/**"
      apiInfo:
        title: The Special Muppet Show API
        description: Use this to get a greeting from Kermit.
        version: 0.1
        termsOfService: use on your own risk
        lisense: APACHE-2.0
        licenseUrl: LICENSE.txt
        contact:
          name: Kermit The Frog
          email: [email protected]
          url: http://muppetshow.biz
    admin:
      basePackage: "biz.muppetshow.admin"
      path: "/admin/**"

Features

The library supports configuration of SpringFox Dockets our of application.yml or application.properties. All properties are prefixed with swagger. Beyond specification of the ApiInfo for every Docket, you can specify a global ApiInfo which will be used for all Dockets, if not overwritten on the Docket level. The following properties are available:

PropertyDescriptionRequiredDefaultExample
swagger.enabledControls if the configuration with properties is enabled. Set to `false` if you want to disable this feature.yestruefalse
swagger.redirectControls if the request to `/` should be redirected to `swagger-ui/`.nofalsetrue
swagger.apiInfoAPI info for all groups.nosee below
swagger.apiInfo.titleTitle of the API for all groups.noMy API
swagger.apiInfo.descriptionDescription of the API for all groups.noThis is a nice API.
swagger.apiInfo.versionVersion of the API for all groups.no1
swagger.apiInfo.termsOfServiceUrlTerms of service of the API for all groups.noUse on your own risk.
swagger.apiInfo.licenseLicense of the API for all groups.noAPACHE 2.0
swagger.apiInfo.licenseUrlLicense url of the API for all groups.nohttp://my.com/license/
swagger.apiInfo.contact.nameContact name of the API for all groups.noKermit The Frog
swagger.apiInfo.contact.emailContact email of the API for all groups.no[email protected]
swagger.apiInfo.contact.urlContact url of the API for all groups.nohttp://muppetshow.biz
swagger.docketsDefines a list of named Docket groups. Every key in this list is a name of the group configures with its elements.noemptysee below
swagger.dockets.[groupname]Defines a Docket group `groupname`.noemptysee below
...[groupname].apiInfoAPI info for this group.nosee below
...[groupname].apiInfo.titleTitle of the API for this group.noMy API
...[groupname].apiInfo.descriptionDescription of the API for this group.noThis is a nice API.
...[groupname].apiInfo.versionVersion of the API for this group.no1
...[groupname].apiInfo.termsOfServiceUrlTerms of service of the API for this group.noUse on your own risk.
...[groupname].apiInfo.licenseLicense of the API for this group.noAPACHE 2.0
...[groupname].apiInfo.licenseUrlLicense url of the API for this group.nohttp://my.com/license/
...[groupname].apiInfo.contact.nameContact name of the API for this group.noKermit The Frog
...[groupname].apiInfo.contact.emailContact email of the API for this group.no[email protected]
...[groupname].apiInfo.contact.urlContact url of the API for this group.nohttp://muppetshow.biz

Building

We use Kotlin and Maven in this project. Make sure you have a recent Apache Maven Version installed or use mnvw wrapper.

Run to build:

./mvnw clean install  

Releasing

We are using gitflow to name and manage branches. Pushes on master branch creates release in OSS nexus. If you are planing to create one and are allowed to push to the master branch, please run to create a new version:

./mvnw gitflow:release-start
./mvnw gitflow:release-finish

Changelog

  • 0.3.0 upgrade to springfox 3.0.0
  • 0.2.0 upgrade to springboot 2.3.1.RELEASE and JDK 11
  • 0.1.0 initial release

Contributing

Issues

https://github.com/toolisticon/springboot-swagger-starter/issues

Contributors

License

BSD-3-Clause