Home

Awesome

kotlin-spring-mvc-template

Spring 5 MVC template with Kotlin and OpenAPI 3.0. (Also Supports Swagger 2.0)

Features automatic request/response validation and interactive API doc

<p align="left"> <img src="https://raw.githubusercontent.com/cdimascio/kotlin-spring-mvc-template/master/assets/spring-mvc-openapi.png" width="600"/> </p>

Features:

Setup

Build

./gradlew build

Format/Lint

./gradlew lintKotlin # see lint errors
./gradlew formatKotlin # attempt to automatically fix lint errors

Run

./gradlew bootRun

Test

./gradlew test

Package / Dist

./gradlew jar

# Run the dist
java -jar ./build/libs/example-service-1.0.0.jar  

Try It

Navigate to http://localhost:8080/api_explorer/index.html

Validate Example

curl -X POST "http://localhost:8080/users" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"me\":\"carmine\"}"

{
  "error": " Object instance has properties which are not allowed by the schema: [\"me\"]",
  "code": 400
}

Interactive Api doc

License

Apache 2.0