function processDefinition()

in eng/tools/typespec-migration-validation/src/document.ts [179:219]


function processDefinition(definition: OpenAPI2Schema): OpenAPI2Schema {
  const newDefinition: OpenAPI2Schema = deepCopy(definition);
  for (const propertyName in definition.properties) {
    const property = definition.properties[propertyName] as OpenAPI2SchemaProperty;
    const processedProperty = processProperty(property);
    newDefinition.properties ??= {};
    newDefinition.properties[propertyName] = processedProperty;
  }
  processEnumInplace(newDefinition);
  if (newDefinition.additionalProperties === false) {
    delete newDefinition.additionalProperties;
  }

  if (newDefinition.allOf) {
    newDefinition.allOf = newDefinition.allOf.map((item) => {
      if ((item as Ref<OpenAPI2Schema>).$ref) {
        const refPath = (item as Ref<OpenAPI2Schema>).$ref;
        if (refPath === "../../../../../common-types/resource-management/v3/types.json#/definitions/Resource") {
          return { ...item, "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ProxyResource" };
        }
      }
      return item;
    });
  }

  if (newDefinition.required) {
    newDefinition.required = newDefinition.required.sort((a, b) => a.localeCompare(b));
  }
  if (configuration.ignoreDescription) {
    delete newDefinition.description;
    if ((newDefinition.items as any)?.description) {
      delete (newDefinition.items as any).description;
    }
  }

  if ((newDefinition as any)["x-ms-azure-resource"]) {
    delete (newDefinition as any)["x-ms-azure-resource"];
  }

  return processPageModel(newDefinition);
}