UNPKG

@autorest/openapi-to-typespec

Version:

Autorest plugin to scaffold a Typespec definition from an OpenAPI document

19 lines (14 loc) 630 B
import { TypespecAlias, TypespecObject } from "../interfaces"; export function addCorePageAlias(typespecObject: TypespecObject): TypespecAlias | undefined { const value = typespecObject.properties?.filter((p) => p.name === "value"); if (!typespecObject.properties?.some((p) => p.name === "nextLink") || !value?.length) { return; } 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; }