@@ -23,12 +23,7 @@ test("LroAzureAsyncOperationHeader should find no errors", () => {
23
23
} ,
24
24
202 : {
25
25
description : "Accepted" ,
26
- headers : {
27
- "Azure-AsyncOperation" : {
28
- description : "The URL where the status of the asynchronous operation can be checked." ,
29
- type : "string" ,
30
- } ,
31
- } ,
26
+ // no header scenario
32
27
} ,
33
28
default : {
34
29
description : "Error" ,
@@ -37,14 +32,15 @@ test("LroAzureAsyncOperationHeader should find no errors", () => {
37
32
} ,
38
33
post : {
39
34
operationId : "foo_post" ,
35
+ "x-ms-long-running-operation" : true ,
40
36
responses : {
41
37
200 : {
42
38
description : "Success" ,
43
39
} ,
44
40
202 : {
45
41
description : "Accepted" ,
46
42
headers : {
47
- "Azure-asyncoperation " : {
43
+ "Azure-AsyncOperation " : {
48
44
description : "The URL where the status of the asynchronous operation can be checked." ,
49
45
type : "string" ,
50
46
} ,
@@ -57,14 +53,12 @@ test("LroAzureAsyncOperationHeader should find no errors", () => {
57
53
} ,
58
54
put : {
59
55
operationId : "foo_put" ,
56
+ "x-ms-long-running-operation" : true ,
60
57
responses : {
61
- 200 : {
62
- description : "Success" ,
63
- } ,
64
- 202 : {
58
+ 204 : {
65
59
description : "Accepted" ,
66
60
headers : {
67
- "azure-asyncOperation " : {
61
+ "Azure-AsyncOperation " : {
68
62
description : "The URL where the status of the asynchronous operation can be checked." ,
69
63
type : "string" ,
70
64
} ,
@@ -75,6 +69,17 @@ test("LroAzureAsyncOperationHeader should find no errors", () => {
75
69
} ,
76
70
} ,
77
71
} ,
72
+ delete : {
73
+ operationId : "foo_put" ,
74
+ responses : {
75
+ 204 : {
76
+ description : "No x-ms-long-running-operation " ,
77
+ } ,
78
+ default : {
79
+ description : "Error" ,
80
+ } ,
81
+ } ,
82
+ } ,
78
83
} ,
79
84
} ,
80
85
}
@@ -90,6 +95,7 @@ test("LroAzureAsyncOperationHeader should find errors with no Azure-AsyncOperati
90
95
"/foo1/operations" : {
91
96
get : {
92
97
operationId : "foo_get" ,
98
+ "x-ms-long-running-operation" : true ,
93
99
responses : {
94
100
200 : {
95
101
description : "Success" ,
@@ -98,7 +104,7 @@ test("LroAzureAsyncOperationHeader should find errors with no Azure-AsyncOperati
98
104
description : "Accepted" ,
99
105
headers : {
100
106
Location : {
101
- description : "The URL where the status of the asynchronous operation can be checked. " ,
107
+ description : "No Azure-AsyncOperation header " ,
102
108
type : "string" ,
103
109
} ,
104
110
} ,
@@ -110,13 +116,19 @@ test("LroAzureAsyncOperationHeader should find errors with no Azure-AsyncOperati
110
116
} ,
111
117
post : {
112
118
operationId : "foo_post" ,
119
+ "x-ms-long-running-operation" : false ,
113
120
responses : {
114
121
200 : {
115
122
description : "Success" ,
116
123
} ,
117
124
202 : {
118
- description : "Accepted" ,
119
- headers : { } ,
125
+ description : "Empty header case" ,
126
+ headers : {
127
+ Location : {
128
+ description : "No Azure-AsyncOperation header" ,
129
+ type : "string" ,
130
+ } ,
131
+ } ,
120
132
} ,
121
133
default : {
122
134
description : "Error" ,
@@ -125,15 +137,16 @@ test("LroAzureAsyncOperationHeader should find errors with no Azure-AsyncOperati
125
137
} ,
126
138
put : {
127
139
operationId : "foo_put" ,
140
+ "x-ms-long-running-operation" : true ,
128
141
responses : {
129
142
200 : {
130
143
description : "Success" ,
131
144
} ,
132
145
202 : {
133
146
description : "Accepted" ,
134
147
headers : {
135
- azureasyncOperation : {
136
- description : "The URL where the status of the asynchronous operation can be checked. " ,
148
+ "azure-asyncOperation1" : {
149
+ description : "check the wrong wording " ,
137
150
type : "string" ,
138
151
} ,
139
152
} ,
@@ -143,16 +156,31 @@ test("LroAzureAsyncOperationHeader should find errors with no Azure-AsyncOperati
143
156
} ,
144
157
} ,
145
158
} ,
159
+ delete : {
160
+ operationId : "foo_put" ,
161
+ "x-ms-long-running-operation" : true ,
162
+ responses : {
163
+ 202 : {
164
+ description : "Accepted" ,
165
+ headers : {
166
+ "azure-asyncOperation" : {
167
+ description : "Check case sensitive scenario" ,
168
+ type : "string" ,
169
+ } ,
170
+ } ,
171
+ } ,
172
+ } ,
173
+ } ,
146
174
} ,
147
175
} ,
148
176
}
149
177
return linter . run ( myOpenApiDocument ) . then ( ( results ) => {
150
178
expect ( results . length ) . toBe ( 3 )
151
- expect ( results [ 0 ] . path . join ( "." ) ) . toBe ( "paths./foo1/operations.get.responses.202.headers" )
179
+ expect ( results [ 0 ] . path . join ( "." ) ) . toBe ( "paths./foo1/operations.get.responses.202.headers.Location " )
152
180
expect ( results [ 0 ] . message ) . toEqual ( ERROR_MESSAGE )
153
- expect ( results [ 1 ] . path . join ( "." ) ) . toBe ( "paths./foo1/operations.post .responses.202.headers" )
181
+ expect ( results [ 1 ] . path . join ( "." ) ) . toBe ( "paths./foo1/operations.put .responses.202.headers.azure-asyncOperation1 " )
154
182
expect ( results [ 1 ] . message ) . toEqual ( ERROR_MESSAGE )
155
- expect ( results [ 2 ] . path . join ( "." ) ) . toBe ( "paths./foo1/operations.put .responses.202.headers" )
183
+ expect ( results [ 2 ] . path . join ( "." ) ) . toBe ( "paths./foo1/operations.delete .responses.202.headers.azure-asyncOperation " )
156
184
expect ( results [ 2 ] . message ) . toEqual ( ERROR_MESSAGE )
157
185
} )
158
186
} )
0 commit comments