Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cdimascio/kotlin-spring-mvc-template
12-factor compliant Spring MVC Kotlin template. Features automatic request/response validation and interactive API doc
https://github.com/cdimascio/kotlin-spring-mvc-template
dotenv kotlin openapi3 spring-boot spring-mvc swagger swagger2
Last synced: 3 months ago
JSON representation
12-factor compliant Spring MVC Kotlin template. Features automatic request/response validation and interactive API doc
- Host: GitHub
- URL: https://github.com/cdimascio/kotlin-spring-mvc-template
- Owner: cdimascio
- Created: 2018-10-05T18:57:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-15T02:10:23.000Z (almost 6 years ago)
- Last Synced: 2024-11-01T23:42:29.576Z (3 months ago)
- Topics: dotenv, kotlin, openapi3, spring-boot, spring-mvc, swagger, swagger2
- Language: Kotlin
- Homepage:
- Size: 2.53 MB
- Stars: 22
- Watchers: 3
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
**Features**:
- Automatic request and response validation via atlassian [OpenApi 3.0](https://swagger.io/docs/specification/about/)
- Automatic documentation generation via [Swagger UI](https://swagger.io/tools/swagger-ui/)
- 12 factor compliant configuration via [java-dotenv](https://github.com/cdimascio/java-dotenv)
- Automatic code formatting and linting via [ktlint](https://ktlint.github.io)
- Fully operational sample REST API
- API integration tests with [Unirest](http://unirest.io/java.html) REST client
- Simple HTTP errors via [japi-errors](https://github.com/cdimascio/japi-errors)
- Dockerfile## Setup
- Clone this repo
- copy `.env.template` to `src/main/resources/.env`## Build
```shell
./gradlew build
```## Format/Lint
```shell
./gradlew lintKotlin # see lint errors
./gradlew formatKotlin # attempt to automatically fix lint errors
```## Run
```shell
./gradlew bootRun
```## Test
```shell
./gradlew test
```## Package / Dist
```shell
./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](http://localhost:8080/api_explorer/index.html)
## Validate Example
```shell
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![](https://raw.githubusercontent.com/cdimascio/kotlin-spring-mvc-template/master/assets/swagger-ui.png)
## License
Apache 2.0