Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 5b4d1f6

Browse files
authored
Shared samples module (#252)
- `shared` module containing shared `POJOs`, `ConstraintDescriptions`, `SnippetMessages` and overridden `auto-authorization` snippet
1 parent a75c772 commit 5b4d1f6

File tree

70 files changed

+3135
-1024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3135
-1024
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ target/
1717
*~
1818

1919
# Gradle
20-
*/build
21-
spring-auto-restdocs-example/.gradle
20+
.gradle/
21+
build/

.travis.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ before_install:
1818
script:
1919
- mvn install -B -V
2020
- cd samples
21+
- mvn install -B -V
2122
- cd java-webmvc
22-
- mvn verify -B
2323
- ./gradlew check
2424
- cd ..
2525
- cd kotlin-webmvc
26-
- mvn verify -B
2726
- ./gradlew check
28-
- cd ..
29-
- cd java-webtestclient
30-
- mvn verify -B
31-
- cd ..
32-
- cd ..
27+
- cd ../..
3328
after_success:
3429
- test "$TRAVIS_BRANCH" = "master"
3530
&& test "$TRAVIS_PULL_REQUEST" = "false"

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,7 @@ <h4 id="contributing-building-build"><a class="link" href="#contributing-buildin
19001900
<div id="footer">
19011901
<div id="footer-text">
19021902
Version 2.0.2-SNAPSHOT<br>
1903-
Last updated 2018-07-19 08:37:35 MESZ
1903+
Last updated 2018-08-01 14:58:47 CEST
19041904
</div>
19051905
</div>
19061906
<link rel="stylesheet" href="highlight/styles/github.min.css">

pom.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454

5555
<properties>
5656
<java.version>1.8</java.version>
57+
<maven.compiler.source>1.8</maven.compiler.source>
58+
<maven.compiler.target>1.8</maven.compiler.target>
5759
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5860
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
5961
<spring-restdocs.version>2.0.1.RELEASE</spring-restdocs.version>
@@ -85,14 +87,6 @@
8587
</execution>
8688
</executions>
8789
</plugin>
88-
<plugin>
89-
<groupId>org.apache.maven.plugins</groupId>
90-
<artifactId>maven-compiler-plugin</artifactId>
91-
<configuration>
92-
<source>${java.version}</source>
93-
<target>${java.version}</target>
94-
</configuration>
95-
</plugin>
9690
<plugin>
9791
<groupId>org.sonatype.plugins</groupId>
9892
<artifactId>nexus-staging-maven-plugin</artifactId>

samples/java-webmvc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ dependencies {
5454
compile "org.springframework.security.oauth:spring-security-oauth2:2.3.0.RELEASE"
5555
compile "org.springframework.data:spring-data-commons"
5656
compile "capital.scalable:spring-auto-restdocs-core:$springAutoRestDocsVersion"
57+
compile "capital.scalable:spring-auto-restdocs-shared-pojos-example:${project.version}"
5758
testCompile("org.springframework.boot:spring-boot-starter-test") {
5859
exclude(module: "commons-logging")
5960
}

samples/java-webmvc/generated-docs/index.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ <h4 id="_example_request"><a class="anchor" href="#_example_request"></a><a clas
11451145
<div class="content">
11461146
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">$ curl 'http://localhost:8080/items' -i -X POST \
11471147
-H 'Content-Type: application/json' \
1148-
-H 'Authorization: Bearer 55ad9296-b11a-4713-8370-a6c617d9656a' \
1148+
-H 'Authorization: Bearer f5f4f322-0af7-4c4b-b323-02f6fcf60514' \
11491149
-d '{"description":"Hot News"}'</code></pre>
11501150
</div>
11511151
</div>
@@ -1382,7 +1382,7 @@ <h4 id="_example_request_2"><a class="anchor" href="#_example_request_2"></a><a
13821382
<div class="content">
13831383
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">$ curl 'http://localhost:8080/items/1' -i -X PUT \
13841384
-H 'Content-Type: application/json' \
1385-
-H 'Authorization: Bearer 55ad9296-b11a-4713-8370-a6c617d9656a' \
1385+
-H 'Authorization: Bearer f5f4f322-0af7-4c4b-b323-02f6fcf60514' \
13861386
-d '{"description":"Hot News"}'</code></pre>
13871387
</div>
13881388
</div>
@@ -1488,7 +1488,7 @@ <h4 id="_example_request_3"><a class="anchor" href="#_example_request_3"></a><a
14881488
<div class="listingblock">
14891489
<div class="content">
14901490
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">$ curl 'http://localhost:8080/items/1' -i -X DELETE \
1491-
-H 'Authorization: Bearer 55ad9296-b11a-4713-8370-a6c617d9656a'</code></pre>
1491+
-H 'Authorization: Bearer f5f4f322-0af7-4c4b-b323-02f6fcf60514'</code></pre>
14921492
</div>
14931493
</div>
14941494
</div>
@@ -1977,25 +1977,25 @@ <h4 id="_example_response_5"><a class="anchor" href="#_example_response_5"></a><
19771977
"sorted" : false,
19781978
"unsorted" : true
19791979
},
1980+
"offset" : 0,
19801981
"pageSize" : 20,
19811982
"pageNumber" : 0,
1982-
"offset" : 0,
1983-
"paged" : true,
1984-
"unpaged" : false
1983+
"unpaged" : false,
1984+
"paged" : true
19851985
},
19861986
"total" : 1,
1987+
"last" : true,
19871988
"totalPages" : 1,
19881989
"totalElements" : 1,
1989-
"last" : true,
1990+
"size" : 20,
1991+
"number" : 0,
1992+
"numberOfElements" : 1,
19901993
"first" : true,
19911994
"sort" : {
19921995
"orders" : [ ],
19931996
"sorted" : false,
19941997
"unsorted" : true
1995-
},
1996-
"numberOfElements" : 1,
1997-
"size" : 20,
1998-
"number" : 0
1998+
}
19991999
}</code></pre>
20002000
</div>
20012001
</div>
@@ -2570,7 +2570,7 @@ <h4 id="_example_request_response_3"><a class="anchor" href="#_example_request_r
25702570
</div>
25712571
<div id="footer">
25722572
<div id="footer-text">
2573-
Last updated 2018-06-15 10:19:16 MESZ
2573+
Last updated 2018-04-10 10:14:19 CEST
25742574
</div>
25752575
</div>
25762576
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">

samples/java-webmvc/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,20 @@
3333

3434
<properties>
3535
<java.version>1.8</java.version>
36+
<maven.compiler.source>1.8</maven.compiler.source>
37+
<maven.compiler.target>1.8</maven.compiler.target>
3638
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3739
<start-class>capital.scalable.restdocs.example.Application</start-class>
3840
<spring-restdocs.version>2.0.1.RELEASE</spring-restdocs.version>
3941
<spring-auto-restdocs.version>2.0.2-SNAPSHOT</spring-auto-restdocs.version>
4042
</properties>
4143

4244
<dependencies>
45+
<dependency>
46+
<groupId>capital.scalable</groupId>
47+
<artifactId>spring-auto-restdocs-shared-pojos-example</artifactId>
48+
<version>${project.version}</version>
49+
</dependency>
4350
<dependency>
4451
<groupId>org.springframework.boot</groupId>
4552
<artifactId>spring-boot-starter-web</artifactId>

samples/java-webmvc/src/main/java/capital/scalable/restdocs/example/items/ItemResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
package capital.scalable.restdocs.example.items;
2121

22-
import static capital.scalable.restdocs.example.items.ItemResponse.EnumType.ONE;
22+
import static capital.scalable.restdocs.example.items.EnumType.ONE;
2323
import static java.util.Collections.singletonList;
2424

2525
import javax.validation.Valid;
@@ -31,10 +31,10 @@
3131
import java.net.URI;
3232
import java.util.Collections;
3333

34+
import capital.scalable.restdocs.example.common.Money;
35+
import capital.scalable.restdocs.example.constraints.English;
36+
import capital.scalable.restdocs.example.constraints.German;
3437
import capital.scalable.restdocs.example.constraints.Id;
35-
import capital.scalable.restdocs.example.items.ItemResponse.Attributes;
36-
import capital.scalable.restdocs.example.items.ItemResponse.Metadata;
37-
import capital.scalable.restdocs.example.items.ItemResponse.Metadata1;
3838
import lombok.Data;
3939
import lombok.Value;
4040
import org.springframework.data.domain.Page;

samples/java-webmvc/src/main/java/capital/scalable/restdocs/example/items/ItemResponse.java

Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,13 @@
1919
*/
2020
package capital.scalable.restdocs.example.items;
2121

22-
import static com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY;
23-
import static com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME;
24-
2522
import javax.validation.Valid;
26-
import javax.validation.constraints.DecimalMax;
27-
import javax.validation.constraints.DecimalMin;
28-
import javax.validation.constraints.Max;
29-
import javax.validation.constraints.Min;
3023
import javax.validation.constraints.NotBlank;
3124
import javax.validation.constraints.NotEmpty;
32-
import javax.validation.constraints.NotNull;
33-
import javax.validation.constraints.Size;
34-
import java.math.BigDecimal;
3525
import java.util.List;
3626

3727
import com.fasterxml.jackson.annotation.JsonIgnore;
38-
import com.fasterxml.jackson.annotation.JsonSubTypes;
39-
import com.fasterxml.jackson.annotation.JsonTypeInfo;
4028
import lombok.AllArgsConstructor;
41-
import lombok.NoArgsConstructor;
42-
import lombok.Value;
4329

4430
/**
4531
* Java object for a single JSON item.
@@ -60,8 +46,7 @@ class ItemResponse {
6046
* <p>
6147
* An example of JsonSubType support.
6248
*
63-
* @see
64-
* <a href="https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations#type-handling">
49+
* @see <a href="https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations#type-handling">
6550
* Jackson type documentation</a>
6651
*/
6752
private Metadata meta;
@@ -89,88 +74,4 @@ class ItemResponse {
8974
public String getDescription() {
9075
return desc;
9176
}
92-
93-
/**
94-
* Various attributes about the item.
95-
*/
96-
@Value
97-
public static class Attributes {
98-
/**
99-
* Textual attribute.
100-
*/
101-
@NotBlank
102-
@Size(min = 2, max = 20)
103-
private String text;
104-
/**
105-
* Integer attribute.
106-
*/
107-
@NotNull
108-
@Min(1)
109-
@Max(10)
110-
private Integer number;
111-
/**
112-
* Boolean attribute.
113-
*/
114-
private Boolean bool;
115-
/**
116-
* Decimal attribute.
117-
*/
118-
@DecimalMin("1")
119-
@DecimalMax("10")
120-
private BigDecimal decimal;
121-
/**
122-
* Amount attribute.
123-
*/
124-
@NotNull
125-
private Money amount;
126-
/**
127-
* Enum attribute.
128-
*/
129-
@NotNull
130-
private EnumType enumType;
131-
}
132-
133-
@NoArgsConstructor
134-
@AllArgsConstructor
135-
@JsonTypeInfo(use = NAME, include = PROPERTY, property = "type", visible = true)
136-
@JsonSubTypes({
137-
@JsonSubTypes.Type(value = Metadata1.class, name = "1"),
138-
@JsonSubTypes.Type(value = Metadata2.class, name = "2")
139-
})
140-
static class Metadata {
141-
/**
142-
* Determines the type of metadata
143-
*/
144-
@NotBlank
145-
private String type;
146-
}
147-
148-
@NoArgsConstructor
149-
static class Metadata1 extends Metadata {
150-
/**
151-
* Tag attribute. Available only if metadata type=1
152-
*/
153-
private String tag;
154-
155-
Metadata1(String type, String tag) {
156-
super(type);
157-
this.tag = tag;
158-
}
159-
}
160-
161-
static class Metadata2 extends Metadata {
162-
/**
163-
* Order attribute. Available only if metadata type=2
164-
*/
165-
private Integer order;
166-
167-
Metadata2(String type, Integer order) {
168-
super(type);
169-
this.order = order;
170-
}
171-
}
172-
173-
enum EnumType {
174-
ONE, TWO
175-
}
17677
}

samples/java-webmvc/src/main/java/capital/scalable/restdocs/example/items/ItemUpdateRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import javax.validation.constraints.NotBlank;
2323
import javax.validation.constraints.Size;
2424

25+
import capital.scalable.restdocs.example.constraints.English;
26+
import capital.scalable.restdocs.example.constraints.German;
2527
import capital.scalable.restdocs.example.constraints.OneOf;
2628
import lombok.Data;
2729
import org.hibernate.validator.constraints.Length;

0 commit comments

Comments
 (0)