|
1 |
| -import { HttpMethod, OpenAPI2Document, OpenAPI2Operation, OpenAPI2Response, Ref, Refable } from "@azure-tools/typespec-autorest"; |
| 1 | +import { HttpMethod, OpenAPI2Document, OpenAPI2Operation, OpenAPI2Response, Refable } from "@azure-tools/typespec-autorest"; |
2 | 2 |
|
3 | 3 | interface Diff {
|
4 | 4 | before: any;
|
@@ -177,23 +177,26 @@ function compareLongRunning(oldOperation: OpenAPI2Operation, newOperation: OpenA
|
177 | 177 | });
|
178 | 178 | }
|
179 | 179 |
|
180 |
| - const newFinalResult = newOperation["x-ms-long-running-operation-options"]?.["final-state-schema"]; |
181 |
| - if (newFinalResult !== getResponseSchema(oldOperation.responses?.["200"])) { |
182 |
| - pathDiffs.push({ |
183 |
| - before: getResponseSchema(oldOperation.responses?.["200"]), |
184 |
| - after: newFinalResult, |
185 |
| - operationId: operationId, |
186 |
| - type: "finalresult", |
187 |
| - level: "error" |
188 |
| - }); |
189 |
| - } |
| 180 | + if (oldLongRunning) { |
| 181 | + const newFinalResult = newOperation["x-ms-long-running-operation-options"]?.["final-state-schema"]; |
| 182 | + const newFinalResultSchema = newFinalResult?.split("/").pop(); |
| 183 | + if (newFinalResultSchema !== getResponseSchema(oldOperation.responses?.["200"])) { |
| 184 | + pathDiffs.push({ |
| 185 | + before: getResponseSchema(oldOperation.responses?.["200"]), |
| 186 | + after: newFinalResultSchema, |
| 187 | + operationId: operationId, |
| 188 | + type: "finalresult", |
| 189 | + level: "error" |
| 190 | + }); |
| 191 | + } |
| 192 | + } |
190 | 193 |
|
191 | 194 | return pathDiffs;
|
192 | 195 | }
|
193 | 196 |
|
194 | 197 | function getResponseSchema(response: Refable<OpenAPI2Response> | undefined): string | undefined {
|
195 |
| - if (response && (response as Ref<OpenAPI2Response>).$ref) { |
196 |
| - const refPath = (response as Ref<OpenAPI2Response>).$ref; |
| 198 | + if (response && (response as OpenAPI2Response).schema && ((response as OpenAPI2Response).schema as any).$ref) { |
| 199 | + const refPath = ((response as OpenAPI2Response).schema as any).$ref; |
197 | 200 | return refPath.split("/").pop();
|
198 | 201 | }
|
199 | 202 |
|
|
0 commit comments