private isEqual()

in src/lib/util/resolveSwagger.ts [289:316]


  private isEqual(parentProperty: any, unwrappedProperty: any): boolean {
    if (!parentProperty) {
      throw new Error("Null parent property.")
    }
    if (!unwrappedProperty) {
      throw new Error("Null unwrapped property.")
    }

    // Note: per https://editor-next.swagger.io/ tooltip when hovering over '$ref',
    // other properties must be ignored when $ref is present:
    //
    //  $ref: string
    //  Any time a subschema is expected, a schema may instead use an object containing a "$ref" property.
    //  The value of the $ref is a URI Reference. Resolved against the current URI base,
    //  it identifies the URI of a schema to use.
    //  All other properties in a "$ref" object MUST be ignored.
    //
    parentProperty = parentProperty.$ref ? this.dereference(parentProperty.$ref) : parentProperty
    unwrappedProperty = unwrappedProperty.$ref ? this.dereference(unwrappedProperty.$ref) : unwrappedProperty

    if ((!parentProperty.type || parentProperty.type === "object") && (!unwrappedProperty.type || unwrappedProperty.type === "object")) {
      return parentProperty === unwrappedProperty
    } else if (parentProperty.type === "array" && unwrappedProperty.type === "array") {
      return this.isEqual(parentProperty.items, unwrappedProperty.items)
    } else {
      return parentProperty.type === unwrappedProperty.type && parentProperty.format === unwrappedProperty.format
    }
  }