diff --git a/buildSrc/src/main/groovy/org/springframework/restdocs/build/SampleBuildConfigurer.groovy b/buildSrc/src/main/groovy/org/springframework/restdocs/build/SampleBuildConfigurer.groovy index 7ce726de..1be930cf 100644 --- a/buildSrc/src/main/groovy/org/springframework/restdocs/build/SampleBuildConfigurer.groovy +++ b/buildSrc/src/main/groovy/org/springframework/restdocs/build/SampleBuildConfigurer.groovy @@ -59,8 +59,8 @@ public class SampleBuildConfigurer { } sampleBuild.doFirst { replaceVersion(new File(this.workingDir, 'build.gradle'), - "springRestdocsVersion = '.*'", - "springRestdocsVersion = '${project.version}'") + "ext\\['spring-restdocs.version'\\] = '.*'", + "ext['spring-restdocs.version'] = '${project.version}'") } } else if (new File(sampleDir, 'pom.xml').isFile()) { diff --git a/samples/rest-assured/build.gradle b/samples/rest-assured/build.gradle index 9ad94239..f4c79f9b 100644 --- a/samples/rest-assured/build.gradle +++ b/samples/rest-assured/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE' + classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE' } } @@ -28,13 +28,14 @@ targetCompatibility = 1.7 ext { snippetsDir = file('build/generated-snippets') - springRestdocsVersion = '1.1.0.BUILD-SNAPSHOT' } +ext['spring-restdocs.version'] = '1.1.0.BUILD-SNAPSHOT' + dependencies { compile 'org.springframework.boot:spring-boot-starter-web' testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile "org.springframework.restdocs:spring-restdocs-restassured:$springRestdocsVersion" + testCompile "org.springframework.restdocs:spring-restdocs-restassured:${project.ext['spring-restdocs.version']}" } test { diff --git a/samples/rest-notes-slate/build.gradle b/samples/rest-notes-slate/build.gradle index 79788c3d..d30ca93e 100644 --- a/samples/rest-notes-slate/build.gradle +++ b/samples/rest-notes-slate/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE' + classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE' } } @@ -24,9 +24,10 @@ targetCompatibility = 1.7 ext { snippetsDir = file('build/generated-snippets') - springRestdocsVersion = '1.1.0.BUILD-SNAPSHOT' } +ext['spring-restdocs.version'] = '1.1.0.BUILD-SNAPSHOT' + dependencies { compile 'org.springframework.boot:spring-boot-starter-data-jpa' compile 'org.springframework.boot:spring-boot-starter-data-rest' @@ -36,7 +37,7 @@ dependencies { testCompile 'com.jayway.jsonpath:json-path' testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile "org.springframework.restdocs:spring-restdocs-mockmvc:$springRestdocsVersion" + testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc' } test { diff --git a/samples/rest-notes-slate/src/main/java/com/example/notes/RestNotesSlate.java b/samples/rest-notes-slate/src/main/java/com/example/notes/RestNotesSlate.java index 32c5ce24..380bebf9 100644 --- a/samples/rest-notes-slate/src/main/java/com/example/notes/RestNotesSlate.java +++ b/samples/rest-notes-slate/src/main/java/com/example/notes/RestNotesSlate.java @@ -17,13 +17,9 @@ package com.example.notes; import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.boot.autoconfigure.SpringBootApplication; -@EnableAutoConfiguration -@ComponentScan -@EnableJpaRepositories +@SpringBootApplication public class RestNotesSlate { public static void main(String[] args) { diff --git a/samples/rest-notes-spring-data-rest/pom.xml b/samples/rest-notes-spring-data-rest/pom.xml index a874c40c..5e1735ed 100644 --- a/samples/rest-notes-spring-data-rest/pom.xml +++ b/samples/rest-notes-spring-data-rest/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 1.2.7.RELEASE + 1.3.3.RELEASE @@ -50,7 +50,6 @@ org.springframework.restdocs spring-restdocs-mockmvc - ${spring-restdocs.version} test diff --git a/samples/rest-notes-spring-data-rest/src/main/asciidoc/api-guide.adoc b/samples/rest-notes-spring-data-rest/src/main/asciidoc/api-guide.adoc index 50498df4..4f7697d7 100644 --- a/samples/rest-notes-spring-data-rest/src/main/asciidoc/api-guide.adoc +++ b/samples/rest-notes-spring-data-rest/src/main/asciidoc/api-guide.adoc @@ -138,6 +138,10 @@ include::{snippets}/notes-list-example/curl-request.adoc[] include::{snippets}/notes-list-example/http-response.adoc[] +[[resources-notes-list-links]] +==== Links + +include::{snippets}/notes-list-example/links.adoc[] [[resources-notes-create]] @@ -183,6 +187,11 @@ include::{snippets}/tags-list-example/curl-request.adoc[] include::{snippets}/tags-list-example/http-response.adoc[] +[[resources-tags-list-links]] +==== Links + +include::{snippets}/tags-list-example/links.adoc[] + [[resources-tags-create]] diff --git a/samples/rest-notes-spring-data-rest/src/main/java/com/example/notes/RestNotesSpringDataRest.java b/samples/rest-notes-spring-data-rest/src/main/java/com/example/notes/RestNotesSpringDataRest.java index 74b98dd0..9df14254 100644 --- a/samples/rest-notes-spring-data-rest/src/main/java/com/example/notes/RestNotesSpringDataRest.java +++ b/samples/rest-notes-spring-data-rest/src/main/java/com/example/notes/RestNotesSpringDataRest.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,9 @@ package com.example.notes; import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.boot.autoconfigure.SpringBootApplication; -@EnableAutoConfiguration -@ComponentScan -@EnableJpaRepositories +@SpringBootApplication public class RestNotesSpringDataRest { public static void main(String[] args) { diff --git a/samples/rest-notes-spring-data-rest/src/test/java/com/example/notes/ApiDocumentation.java b/samples/rest-notes-spring-data-rest/src/test/java/com/example/notes/ApiDocumentation.java index cbcaeb3f..2db8fcb4 100644 --- a/samples/rest-notes-spring-data-rest/src/test/java/com/example/notes/ApiDocumentation.java +++ b/samples/rest-notes-spring-data-rest/src/test/java/com/example/notes/ApiDocumentation.java @@ -133,8 +133,12 @@ public class ApiDocumentation { this.mockMvc.perform(get("/notes")) .andExpect(status().isOk()) .andDo(document("notes-list-example", + links( + linkWithRel("self").description("Canonical link for this resource"), + linkWithRel("profile").description("The ALPS profile for this resource")), responseFields( - fieldWithPath("_embedded.notes").description("An array of <>")))); + fieldWithPath("_embedded.notes").description("An array of <>"), + fieldWithPath("_links").description("<> to other resources")))); } @Test @@ -195,9 +199,11 @@ public class ApiDocumentation { .andExpect(jsonPath("body", is(note.get("body")))) .andExpect(jsonPath("_links.self.href", is(noteLocation))) .andExpect(jsonPath("_links.tags", is(notNullValue()))) + .andDo(print()) .andDo(document("note-get-example", links( - linkWithRel("self").description("This <>"), + linkWithRel("self").description("Canonical link for this <>"), + linkWithRel("note").description("This <>"), linkWithRel("tags").description("This note's tags")), responseFields( fieldWithPath("title").description("The title of the note"), @@ -217,8 +223,12 @@ public class ApiDocumentation { this.mockMvc.perform(get("/tags")) .andExpect(status().isOk()) .andDo(document("tags-list-example", + links( + linkWithRel("self").description("Canonical link for this resource"), + linkWithRel("profile").description("The ALPS profile for this resource")), responseFields( - fieldWithPath("_embedded.tags").description("An array of <>")))); + fieldWithPath("_embedded.tags").description("An array of <>"), + fieldWithPath("_links").description("<> to other resources")))); } @Test @@ -295,7 +305,8 @@ public class ApiDocumentation { .andExpect(jsonPath("name", is(tag.get("name")))) .andDo(document("tag-get-example", links( - linkWithRel("self").description("This <>"), + linkWithRel("self").description("Canonical link for this <>"), + linkWithRel("tag").description("This <>"), linkWithRel("notes").description("The <> that have this tag")), responseFields( fieldWithPath("name").description("The name of the tag"), diff --git a/samples/rest-notes-spring-hateoas/build.gradle b/samples/rest-notes-spring-hateoas/build.gradle index 555d25ec..7941829f 100644 --- a/samples/rest-notes-spring-hateoas/build.gradle +++ b/samples/rest-notes-spring-hateoas/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE' + classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE' } } @@ -28,9 +28,10 @@ targetCompatibility = 1.7 ext { snippetsDir = file('build/generated-snippets') - springRestdocsVersion = '1.1.0.BUILD-SNAPSHOT' } +ext['spring-restdocs.version'] = '1.1.0.BUILD-SNAPSHOT' + dependencies { compile 'org.springframework.boot:spring-boot-starter-data-jpa' compile 'org.springframework.boot:spring-boot-starter-hateoas' @@ -40,7 +41,7 @@ dependencies { testCompile 'com.jayway.jsonpath:json-path' testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile "org.springframework.restdocs:spring-restdocs-mockmvc:$springRestdocsVersion" + testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc' } test { diff --git a/samples/rest-notes-spring-hateoas/src/main/java/com/example/notes/RestNotesSpringHateoas.java b/samples/rest-notes-spring-hateoas/src/main/java/com/example/notes/RestNotesSpringHateoas.java index c51ecee0..9ad46158 100644 --- a/samples/rest-notes-spring-hateoas/src/main/java/com/example/notes/RestNotesSpringHateoas.java +++ b/samples/rest-notes-spring-hateoas/src/main/java/com/example/notes/RestNotesSpringHateoas.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,9 @@ package com.example.notes; import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.boot.autoconfigure.SpringBootApplication; -@EnableAutoConfiguration -@ComponentScan -@EnableJpaRepositories +@SpringBootApplication public class RestNotesSpringHateoas { public static void main(String[] args) { diff --git a/samples/testng/build.gradle b/samples/testng/build.gradle index a6eeb77a..7683e955 100644 --- a/samples/testng/build.gradle +++ b/samples/testng/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE' + classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE' } } @@ -28,8 +28,8 @@ targetCompatibility = 1.7 ext { snippetsDir = file('build/generated-snippets') - springRestdocsVersion = '1.1.0.BUILD-SNAPSHOT' } +ext['spring-restdocs.version'] = '1.1.0.BUILD-SNAPSHOT' dependencies { compile 'org.springframework.boot:spring-boot-starter-web' @@ -37,7 +37,7 @@ dependencies { exclude group: 'junit', module: 'junit;' } testCompile 'org.testng:testng:6.9.10' - testCompile "org.springframework.restdocs:spring-restdocs-mockmvc:$springRestdocsVersion" + testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc' } test {