Skip to content

[Bug]: allOf reference not resolved fully #2270

@julianmclain

Description

@julianmclain

Description

Setting resolveFully(true) does not resolve $ref pointers inside allOf schemas. The $ref remains as a pointer.

This is while Parsing OpenAPI 3.0.x specs. In case it's relevant, the allOf I'm trying to parse contains a $ref AND a raw schema as the 2nd element.

Affected Version

  • 2.1.22 (latest)

Steps to Reproduce

Full reproducible example here: https://github.com/julianmclain/swagger-parser-allOf-resolution

Set ParseOptions.setResolve(true) and setResolveFully(true) and parse a spec with a schema using allOf:

String spec = """
    {
      "openapi": "3.0.3",
      "info": { "title": "Test", "version": "1.0" },
      "paths": {},
      "components": {
        "schemas": {
          "SObject": {
            "type": "object",
            "properties": {
              "attributes": { "type": "object" }
            }
          },
          "Contact": {
            "allOf": [
              { "$ref": "#/components/schemas/SObject" },
              {
                "type": "object",
                "properties": {
                  "FirstName": { "type": "string" }
                }
              }
            ]
          }
        }
      }
    }
    """;

ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(true);

SwaggerParseResult result = new OpenAPIV3Parser().readContents(spec, null, options);
Schema<?> contact = result.getOpenAPI().getComponents().getSchemas().get("Contact");

System.out.println(Json.pretty(contact.getAllOf()));

Expected Behavior

The $ref is resolved to the referenced schema content, i.e.

[ {
  "type" : "object",
  "properties" : {
    "attributes" : {
      "type" : "object"
    }
  }
}, {
  "type" : "object",
  "properties" : {
    "FirstName" : {
      "type" : "string"
    }
  }
} ]

Actual Behavior

The reference to "#/components/schemas/SObject"` is unresolved:

[ {
  "$ref" : "#/components/schemas/SObject"
}, {
  "type" : "object",
  "properties" : {
    "FirstName" : {
      "type" : "string"
    }
  }
} ]

Environment

  • Java version: 21
  • Build tool: Gradle 9.0
  • OS: macOS

Additional Context

There were related issues, but they were marked resolved so I'm not sure if they're relevant: #1157, #1161, #1538

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions