This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RestTemplate restTemplate = new RestTemplate(); | |
| Set<HttpMethod> allowHeaders = restTemplate.optionsForAllow(baseUrl); | |
| URI uri = new URI(baseUrl); | |
| Set<HttpMethod> allowHeadersURI = restTemplate.optionsForAllow(uri); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RestTemplate restTemplate = new RestTemplate(); | |
| URI uri = new URI(baseUrl); | |
| restTemplate.delete(baseUrl); | |
| restTemplate.delete(uri); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RestTemplate restTemplate = new RestTemplate(); | |
| URI uri = new URI(baseUrl); | |
| String body = "The Body"; | |
| restTemplate.put(baseUrl, body); | |
| restTemplate.put(uri, body); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RestTemplate restTemplate = new RestTemplate(); | |
| URI uri = new URI(baseUrl); | |
| String body = "The Body"; | |
| ResponseEntity<String> response=restTemplate.postForEntity(baseUrl, body, String.class); | |
| HttpEntity<String> request = new HttpEntity<>(body); | |
| ResponseEntity<String> responseExchange=restTemplate.exchange(baseUrl, HttpMethod.POST, request, String.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RestTemplate restTemplate = new RestTemplate(); | |
| ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class); | |
| ResponseEntity<String> responseExchange = restTemplate.exchange(baseUrl, HttpMethod.GET, null, String.class); | |
| URI uri = new URI(baseUrl); | |
| ResponseEntity<String> responseURI = restTemplate.getForEntity(uri, String.class); | |
| ResponseEntity<String> responseExchangeURI = restTemplate.exchange(uri, HttpMethod.GET, null, String.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Simple CRUD RESTful controller for {@linkplain User} object | |
| */ | |
| @RestController | |
| @RequestMapping("/api/v1/users") | |
| public class UserController { | |
| private final UserDatastore userDatastore; | |
| @Autowired |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @WebAppConfiguration | |
| @RunWith(SpringJUnit4ClassRunner.class) | |
| @SpringApplicationConfiguration(classes = Application.class) | |
| public class UserControllerDocumentation { | |
| // setup MockMVC, RestDocumentation etc omitted | |
| /** | |
| * All documentation production happens here. | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <plugin> | |
| <artifactId>maven-resources-plugin</artifactId> | |
| <version>2.7</version> | |
| <executions> | |
| <execution> | |
| <id>copy-resources</id> | |
| <phase>prepare-package</phase> | |
| <goals> | |
| <goal>copy-resources</goal> | |
| </goals> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [[resources-get-users]] | |
| == Listing users | |
| A `GET` request will list all of the users. | |
| === Response structure | |
| include::{snippets}/getUsers/response-fields.adoc[] | |
| === Example request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Rule | |
| public final RestDocumentation restDocumentation = new RestDocumentation( | |
| "target/generated-snippets" | |
| ); | |
| @Autowired | |
| private WebApplicationContext context; | |
| private MockMvc mockMvc; | |