[Bug]: allOf reference not resolved fully
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start with the OpenAPIV3Parser and ParseOptions behavior shown in the issue, then reproduce the case from the linked repository using the provided OpenAPI 3.0.3 document. Trace why resolveFully(true) leaves the $ref inside Contact's allOf unresolved; done means the referenced SObject schema is expanded while the raw second allOf schema remains intact.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from swagger-api/swagger-parser
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
swagger-api/swagger-parser#2386 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
swagger-api/swagger-parser#2168 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
swagger-api/swagger-parser#1922 · 2 comments · 1 reaction ·
-
[Bug]: Regression: resolveFully fails when components key does not match external file basename OpenBug
Difficulty 4/5 3-5 days Newbie friendliness 58/100
swagger-api/swagger-parser#2399 · 3 comments ·
-
Bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
swagger-api/swagger-parser#2395 ·
All issues in swagger-api/swagger-parser
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100