Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mechero/spring-boot-restcontroller
Sample code for a RestController in Spring using Swagger
https://github.com/mechero/spring-boot-restcontroller
rest-api restcontroller spring-boot
Last synced: 2 months ago
JSON representation
Sample code for a RestController in Spring using Swagger
- Host: GitHub
- URL: https://github.com/mechero/spring-boot-restcontroller
- Owner: mechero
- Created: 2017-02-27T18:49:34.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-26T16:10:25.000Z (5 months ago)
- Last Synced: 2024-10-24T15:55:49.670Z (3 months ago)
- Topics: rest-api, restcontroller, spring-boot
- Language: Shell
- Homepage: https://thepracticaldeveloper.com/2017/03/04/restcontroller-spring-boot-example-with-springfox-swagger/
- Size: 91.8 KB
- Stars: 6
- Watchers: 1
- Forks: 20
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Spring Boot @RestController Example
## Description
This project contains the sample code used in [The Practical Developer Blog](https://thepracticaldeveloper.com/2017/03/04/restcontroller-spring-boot-example-with-springfox-swagger/). It's a Spring Boot application with one plain Java object (`SpanishGreeting`) and a Spring Controller `SpanishGreetingController`.
The main goal of the project is to show how to write a `@RestController` in Spring Boot and include documentation with Swagger.
## How does it work?You can use the endpoints behind `http://localhost:8080/spanish-greetings`. If you append `/random` to a `GET` request you'll receive a random Spanish greeting (which are actually hard-coded). You can also `GET` them by `id` (only from 1 to 3). To create a new one, you need to perform a `POST` operation.
Actually, much better if you just start the application and navigate to `http://localhost:8080/swagger-ui.html`. There you'll find a nice API documentation thanks to Swagger. Moreover, *you can play with it*.
![Swagger Documentation](images/swagger.png)