function processPageModel()

in eng/tools/typespec-migration-validation/src/document.ts [271:299]


function processPageModel(definition: OpenAPI2Schema): OpenAPI2Schema {
  const newDefinition: OpenAPI2Schema = deepCopy(definition);

  const propertyCount = Object.keys(definition.properties ?? {}).length;
  if (propertyCount !== 2) {
    return newDefinition;
  }

  const valueProperty = definition.properties?.["value"];
  if (!valueProperty || (valueProperty as OpenAPI2Schema).type !== "array") {
    return newDefinition;
  }

  const nextLinkProperty = definition.properties?.["nextLink"];
  if (!nextLinkProperty || (nextLinkProperty as OpenAPI2Schema).type !== "string") {
    return newDefinition;
  }

  newDefinition.description = "[Placeholder] Discription for page model";
  newDefinition.properties!["value"]!.description = "[Placeholder] Discription for value property";
  newDefinition.properties!["nextLink"]!.description = "[Placeholder] Discription for nextLink property";
  (newDefinition.properties!["nextLink"] as any)["format"] = "uri";
  newDefinition.required = ["value"];
  if (newDefinition.properties!["nextLink"]?.readOnly) {
    delete newDefinition.properties!["nextLink"]?.readOnly;
  }

  return newDefinition;
}