@autorest/openapi-to-typespec
Version:
Autorest plugin to scaffold a Typespec definition from an OpenAPI document
23 lines • 1.14 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.addCorePageAlias = void 0;
function addCorePageAlias(typespecObject) {
var _a, _b, _c;
if (!((_a = typespecObject.decorators) === null || _a === void 0 ? void 0 : _a.some((d) => d.name === "pagedResult"))) {
return;
}
const value = (_b = typespecObject.properties) === null || _b === void 0 ? void 0 : _b.filter((p) => p.name === "value");
if (!((_c = typespecObject.properties) === null || _c === void 0 ? void 0 : _c.some((p) => p.name === "nextLink")) || !(value === null || value === void 0 ? void 0 : value.length)) {
return;
}
typespecObject.decorators = typespecObject.decorators.filter((d) => d.name !== "pagedResult");
typespecObject.properties = typespecObject.properties.filter((p) => p.name !== "nextLink" && p.name !== "value");
typespecObject.alias = {
alias: "Azure.Core.Page",
params: [value[0].type.replace("[]", "")],
module: "@azure-tools/typespec-azure-core",
};
return;
}
exports.addCorePageAlias = addCorePageAlias;
//# sourceMappingURL=alias.js.map
;