Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Question] [Bug]: Inconsistent Relative Reference Resolution in Nested Schema Contexts

Open
#2,256 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Start with the reproduction context in OpenAPITools/openapi-generator#21492 and inspect how parentDirectory is handled while resolving relative $ref values through nested additionalProperties schemas. Verify the behavior against the OpenAPI 3.0 file-relative rule, including both path-file and schema-file references; done means nested references resolve consistently without build failures.

Written by the indexing model from the issue text.

Description

Question

Question

There seems to be a bug when resolving nested schemas.

OpenAPI Generator incorrectly resolves relative $ref paths in schema files when they are referenced through nested contexts (like additionalProperties). The reference resolution context switches from file-relative to root-relative depending on the nesting level, causing build failures when using standard file-relative references.

This creates inconsistent behavior where:

References from path files work correctly using file-relative paths (../components/schemas/...)
References from schema files fail when using file-relative paths (NestedData.yaml)

This violates the OpenAPI 3.0 specification where all relative references should be resolved from the containing file's location.

Any ideas? parentDirectory seems to be resolved wrongly in this case?

Affected Version

Latest

Context

This issue first reported here: https://github.com/OpenAPITools/openapi-generator/issues/21492 (the project uses this library)

# Example OpenAPI or Swagger definition (optional)

Additional Details

Checklist

  • I have searched the existing issues and documentation before asking.
  • I have provided enough information for others to understand my question.
Dominant language
Java
Stars
868
Forks
560
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from swagger-api/swagger-parser

All issues in swagger-api/swagger-parser

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.