File tree 3 files changed +77
-0
lines changed
java/com/github/bjansen/ssv
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,19 @@ void checkUnknownDefinition() throws IOException {
164
164
assertTrue (e .getMessage ().contains ("Unknown definition /definitions/Blablabla" ));
165
165
}
166
166
167
+ @ Test
168
+ void should_support_references_to_definitions_in_same_file () throws IOException , ProcessingException {
169
+ // Given
170
+ SwaggerValidator validator = buildValidator ("/references/spec-issue14.json" );
171
+ JsonNode sample = buildSample ("/references/sample-issue14.json" );
172
+
173
+ // When
174
+ final ProcessingReport report = validator .validate (sample , "/definitions/Response" );
175
+
176
+ // Then
177
+ assertTrue (report .isSuccess ());
178
+ }
179
+
167
180
private SwaggerValidator buildValidator (String pathToSpec ) throws IOException {
168
181
InputStream spec = getClass ().getResourceAsStream (pathToSpec );
169
182
return SwaggerValidator .forYamlSchema (new InputStreamReader (spec ));
Original file line number Diff line number Diff line change
1
+ {
2
+ "asyncRequestId" : " qsdf" ,
3
+ "result" : {
4
+
5
+ }
6
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "swagger" : " 2.0" ,
3
+ "info" : {
4
+ "title" : " Sample API" ,
5
+ "version" : " 1"
6
+ },
7
+ "definitions" : {
8
+ "Response" : {
9
+ "type" : " object" ,
10
+ "required" : [
11
+ " asyncRequestId" ,
12
+ " result"
13
+ ],
14
+ "properties" : {
15
+ "asyncRequestId" : {
16
+ "type" : " string"
17
+ },
18
+ "beginTime" : {
19
+ "type" : " string" ,
20
+ "format" : " date-time"
21
+ },
22
+ "endTime" : {
23
+ "type" : " string" ,
24
+ "format" : " date-time"
25
+ },
26
+ "id" : {
27
+ "type" : " string"
28
+ },
29
+ "name" : {
30
+ "type" : " string"
31
+ },
32
+ "result" : {
33
+ "$ref" : " #/definitions/AsyncResult"
34
+ },
35
+ "sceuid" : {
36
+ "type" : " string"
37
+ },
38
+ "type" : {
39
+ "type" : " string"
40
+ },
41
+ "userId" : {
42
+ "type" : " string"
43
+ },
44
+ "version" : {
45
+ "type" : " string"
46
+ }
47
+ }
48
+ },
49
+ "AsyncResult" : {
50
+ "type" : " object" ,
51
+ "properties" : {
52
+ "status" : {
53
+ "type" : " string"
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
You can’t perform that action at this time.
0 commit comments