UNPKG

@autorest/openapi-to-cadl

Version:

Autorest plugin to scaffold a Typespec definition from an OpenAPI document

37 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasLROExtension = exports.markLRO = void 0; const codemodel_1 = require("@autorest/codemodel"); const schemas_1 = require("./schemas"); function markLRO(codeModel) { var _a, _b; for (const operationGroup of codeModel.operationGroups) { for (const operation of operationGroup.operations) { (_a = operation.extensions) !== null && _a !== void 0 ? _a : {}; if (!hasLROExtension(operation)) { continue; } for (const response of (_b = operation.responses) !== null && _b !== void 0 ? _b : []) { if (!(0, schemas_1.isResponseSchema)(response)) { continue; } if (!(0, codemodel_1.isObjectSchema)(response.schema)) { continue; } response.schema.language.default.lro = { ...response.schema.language.default.lro, isLRO: true, }; // TODO: mark the response as an LRO } } } } exports.markLRO = markLRO; function hasLROExtension(operation) { var _a, _b; return (((_a = operation.extensions) === null || _a === void 0 ? void 0 : _a["x-ms-long-running-operation"]) || ((_b = operation.extensions) === null || _b === void 0 ? void 0 : _b["x-ms-long-running-operation-options"])); } exports.hasLROExtension = hasLROExtension; //# sourceMappingURL=lro.js.map