Skip to content

Commit

Permalink
Add Swagger UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
cstroe committed Dec 14, 2018
1 parent b7debdb commit 0628f5a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/main/kotlin/cloud/cosmin/checklister/config/SwaggerConfig.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
package cloud.cosmin.checklister.config

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import springfox.documentation.builders.RequestHandlerSelectors.basePackage
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2

@Configuration
@EnableSwagger2
class SwaggerConfig {
@Bean
fun checklisterApi(): Docket {
val docket = Docket(DocumentationType.SWAGGER_2);
docket.select()
.apis(basePackage("cloud.cosmin.checklister.rest"))
.build()
return docket
}
}
13 changes: 11 additions & 2 deletions src/main/kotlin/cloud/cosmin/checklister/rest/IndexController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ package cloud.cosmin.checklister.rest

import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import springfox.documentation.annotations.ApiIgnore

@RestController
@ApiIgnore
class IndexController {
@RequestMapping(path = arrayOf("/"), produces = arrayOf("text/plain"))
@RequestMapping(path = arrayOf("/"), produces = arrayOf("text/html"))
fun index(): String {
return "Hello!"
return """
<html><body>
<h1>Checklister</h1>
<p>
<a href="swagger-ui.html">Swagger UI</a>
</p>
</body></html>
""".trimIndent()
}
}

0 comments on commit 0628f5a

Please sign in to comment.