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 { | |
| @Rule | |
| public final RestDocumentation restDocumentation = new RestDocumentation( | |
| "target/generated-snippets" | |
| ); |
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
| <dependency> | |
| <groupId>org.springframework.restdocs</groupId> | |
| <artifactId>spring-restdocs-mockmvc</artifactId> | |
| <scope>test</scope> | |
| </dependency> |
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
| <properties> | |
| <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory> | |
| </properties> |
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> | |
| <groupId>org.apache.maven.plugins</groupId> | |
| <artifactId>maven-surefire-plugin</artifactId> | |
| <configuration> | |
| <includes> | |
| <include>**/*Documentation.java</include> | |
| </includes> | |
| </configuration> | |
| </plugin> | |
| <plugin> |
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; | |
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
| <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
| @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
| /** | |
| * 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
| 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); |
OlderNewer