Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pjagielski/spring-boot-swagger
Dead simple Swagger config for Spring Boot
https://github.com/pjagielski/spring-boot-swagger
Last synced: 2 days ago
JSON representation
Dead simple Swagger config for Spring Boot
- Host: GitHub
- URL: https://github.com/pjagielski/spring-boot-swagger
- Owner: pjagielski
- License: apache-2.0
- Created: 2014-05-05T21:04:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-30T23:05:58.000Z (about 10 years ago)
- Last Synced: 2024-04-16T11:11:22.555Z (7 months ago)
- Language: Java
- Size: 221 KB
- Stars: 18
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Spring-boot-swagger
===================
Dead simple [Swagger](https://github.com/wordnik/swagger-ui) config for [Spring Boot](https://github.com/spring-projects/spring-boot).[![Build Status](https://travis-ci.org/pjagielski/spring-boot-swagger.svg?branch=master)](https://travis-ci.org/pjagielski/spring-boot-swagger)
Motivation
==========
Spring Boot is one of the hottest JVM frameworks in the microservice area. The only missing part for me is integration with Swagger — de facto standard for documenting REST services. There is a great [swagger-springmvc](https://github.com/martypitt/swagger-springmvc) library for Spring MVC, but its configuration seems to be too verbose for microservices. This project provides sensible defaults for swagger-springmvc which let you expose Swagger docs in just a few lines of code.Usage
=====
Spring-boot-swagger is available for download from the Maven Central repository.Maven:
```xmlcom.github.pjagielski.spring-boot-swagger
spring-boot-swagger
0.1```
Grab:
```groovy
@Grab('com.github.pjagielski.spring-boot-swagger:spring-boot-swagger:0.1')
```Examples
========
Sample `app.groovy`:
```groovy
@Grab('org.springframework.boot:spring-boot-starter-actuator:1.0.2.RELEASE')
@Grab('org.springframework:spring-web:4.0.3.RELEASE')
@Grab('com.github.pjagielski.spring-boot-swagger:spring-boot-swagger:0.1')import com.mangofactory.swagger.configuration.SpringSwaggerConfig
import com.wordnik.swagger.annotations.ApiOperation
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import springboot.swagger.SpringBootSwaggerConfigimport static org.springframework.web.bind.annotation.RequestMethod.GET
@RestController
class SampleController {@RequestMapping(value = "/messages", method = GET)
@ApiOperation("hello world")
Message hello() {
new Message(text: "Hello world!")
}
}class Message {
String text
}@Configuration
@Import(SpringSwaggerConfig)
class SwaggerConfig extends SpringBootSwaggerConfig {@Override
protected List getIncludePatterns() {
['/messages.*']
}@Override
protected String getSwaggerGroup() {
'messages'
}
}
```