File tree Expand file tree Collapse file tree 4 files changed +171
-0
lines changed
src/Microsoft.OpenApi/Services
test/Microsoft.OpenApi.Tests Expand file tree Collapse file tree 4 files changed +171
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ public static class OpenApiFilterService
81
81
var openApiOperations = GetOpenApiOperations ( rootNode , url , apiVersion ) ;
82
82
if ( openApiOperations == null )
83
83
{
84
+ Console . WriteLine ( $ "The url { url } could not be found in the OpenApi description") ;
84
85
continue ;
85
86
}
86
87
Original file line number Diff line number Diff line change 47
47
<None Update =" UtilityFiles\postmanCollection_ver3.json" >
48
48
<CopyToOutputDirectory >Always</CopyToOutputDirectory >
49
49
</None >
50
+ <None Update =" UtilityFiles\postmanCollection_ver4.json" >
51
+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
52
+ </None >
50
53
<None Update =" UtilityFiles\Todo.xml" >
51
54
<CopyToOutputDirectory >Always</CopyToOutputDirectory >
52
55
</None >
Original file line number Diff line number Diff line change @@ -103,6 +103,28 @@ public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument()
103
103
Assert . Equal ( "The urls in the Postman collection supplied could not be found." , message ) ;
104
104
}
105
105
106
+ [ Fact ]
107
+ public void ContinueProcessingWhenUrlsInCollectionAreMissingFromSourceDocument ( )
108
+ {
109
+ // Arrange
110
+ var filePath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "UtilityFiles\\ postmanCollection_ver4.json" ) ;
111
+ var fileInput = new FileInfo ( filePath ) ;
112
+ var stream = fileInput . OpenRead ( ) ;
113
+
114
+ // Act
115
+ var requestUrls = OpenApiService . ParseJsonCollectionFile ( stream , _logger ) ;
116
+ var pathCount = requestUrls . Count ;
117
+ var predicate = OpenApiFilterService . CreatePredicate ( requestUrls : requestUrls , source : _openApiDocumentMock ) ;
118
+ var subsetOpenApiDocument = OpenApiFilterService . CreateFilteredDocument ( _openApiDocumentMock , predicate ) ;
119
+ var subsetPathCount = subsetOpenApiDocument . Paths . Count ;
120
+
121
+ // Assert
122
+ Assert . NotNull ( subsetOpenApiDocument ) ;
123
+ Assert . NotEmpty ( subsetOpenApiDocument . Paths ) ;
124
+ Assert . Equal ( 2 , subsetPathCount ) ;
125
+ Assert . NotEqual ( pathCount , subsetPathCount ) ;
126
+ }
127
+
106
128
[ Fact ]
107
129
public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArgumentsArePassed ( )
108
130
{
Original file line number Diff line number Diff line change
1
+ {
2
+ "info" : {
3
+ "_postman_id" : " 43402ca3-f018-7c9b-2315-f176d9b171a3" ,
4
+ "name" : " Graph-Collection" ,
5
+ "schema" : " https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6
+ },
7
+ "item" : [
8
+ {
9
+ "name" : " users-GET" ,
10
+ "request" : {
11
+ "method" : " GET" ,
12
+ "url" : {
13
+ "raw" : " https://graph.microsoft.com/v1.0/users" ,
14
+ "protocol" : " https" ,
15
+ "host" : [
16
+ " graph" ,
17
+ " microsoft" ,
18
+ " com"
19
+ ],
20
+ "path" : [
21
+ " v1.0" ,
22
+ " users"
23
+ ]
24
+ }
25
+ }
26
+ },
27
+ {
28
+ "name" : " users-POST" ,
29
+ "request" : {
30
+ "method" : " POST" ,
31
+ "url" : {
32
+ "raw" : " https://graph.microsoft.com/v1.0/users" ,
33
+ "protocol" : " https" ,
34
+ "host" : [
35
+ " graph" ,
36
+ " microsoft" ,
37
+ " com"
38
+ ],
39
+ "path" : [
40
+ " v1.0" ,
41
+ " users"
42
+ ]
43
+ }
44
+ }
45
+ },
46
+ {
47
+ "name" : " /appCatalogs" ,
48
+ "request" : {
49
+ "method" : " GET" ,
50
+ "url" : {
51
+ "raw" : " https://graph.microsoft.com/v1.0/appCatalogs" ,
52
+ "protocol" : " https" ,
53
+ "host" : [
54
+ " graph" ,
55
+ " microsoft" ,
56
+ " com"
57
+ ],
58
+ "path" : [
59
+ " v1.0" ,
60
+ " appCatalogs"
61
+ ]
62
+ }
63
+ }
64
+ },
65
+ {
66
+ "name" : " /agreementAcceptances" ,
67
+ "request" : {
68
+ "method" : " GET" ,
69
+ "url" : {
70
+ "raw" : " https://graph.microsoft.com/v1.0/agreementAcceptances" ,
71
+ "protocol" : " https" ,
72
+ "host" : [
73
+ " graph" ,
74
+ " microsoft" ,
75
+ " com"
76
+ ],
77
+ "path" : [
78
+ " v1.0" ,
79
+ " agreementAcceptances"
80
+ ]
81
+ }
82
+ }
83
+ },
84
+ {
85
+ "name" : " {user-id}-GET" ,
86
+ "request" : {
87
+ "method" : " GET" ,
88
+ "url" : {
89
+ "raw" : " https://graph.microsoft.com/v1.0/users/{user-id}" ,
90
+ "protocol" : " https" ,
91
+ "host" : [
92
+ " graph" ,
93
+ " microsoft" ,
94
+ " com"
95
+ ],
96
+ "path" : [
97
+ " v1.0" ,
98
+ " users" ,
99
+ " {user-id}"
100
+ ]
101
+ }
102
+ }
103
+ },
104
+ {
105
+ "name" : " {user-id}-PATCH" ,
106
+ "request" : {
107
+ "method" : " PATCH" ,
108
+ "url" : {
109
+ "raw" : " https://graph.microsoft.com/v1.0/users/{user-id}" ,
110
+ "protocol" : " https" ,
111
+ "host" : [
112
+ " graph" ,
113
+ " microsoft" ,
114
+ " com"
115
+ ],
116
+ "path" : [
117
+ " v1.0" ,
118
+ " users" ,
119
+ " {user-id}"
120
+ ]
121
+ }
122
+ }
123
+ },
124
+ {
125
+ "name" : " {user-id}-DELETE" ,
126
+ "request" : {
127
+ "method" : " DELETE" ,
128
+ "url" : {
129
+ "raw" : " https://graph.microsoft.com/v1.0/users/{user-id}" ,
130
+ "protocol" : " https" ,
131
+ "host" : [
132
+ " graph" ,
133
+ " microsoft" ,
134
+ " com"
135
+ ],
136
+ "path" : [
137
+ " v1.0" ,
138
+ " users" ,
139
+ " {user-id}"
140
+ ]
141
+ }
142
+ }
143
+ }
144
+ ]
145
+ }
You can’t perform that action at this time.
0 commit comments