Repository navigation
Description
Motivation
Consumers of this codegen (e.g. quarkus-openapi-generator) currently have to pre-resolve
multi-file OpenAPI specs themselves before handing a single JSON document to this library,
because OpenApi2JaxRs / DocumentPreProcessor only resolve $refs that point inside the
same document (#/components/schemas/...). There is no support for $refs that point to
another file, e.g.:
# module1.yaml
paths:
/pets:
get:
responses:
'200':
content:
application/json:
schema:
$ref: './common-spec.yaml#/components/schemas/Pet'Today, quarkus-openapi-generator works around this by parsing the entry spec with
swagger-parser (setResolve(true), setResolveFully(true), setResolveCombinators(true)),
flattening every external $ref into a single resolved document, and only then handing the
JSON to this project. That means every consumer of this library has to reimplement the same
workaround, using a completely different OpenAPI object model (swagger-core) than the one this
project uses internally (io.apitomy.datamodels). It was also the root cause of a separate bug
where OpenAPI 3.1 schema types were silently dropped during that round-trip (see companion
issue: type/types lost for 3.1 — link once filed).
Proposal
Teach this project's own document loading / DocumentPreProcessor pipeline to resolve relative
$refs against sibling files on disk (and, ideally, combinators like allOf/oneOf/anyOf
that span files), using the existing io.apitomy.datamodels model, so consumers can pass a
multi-file spec's entry document directly without a separate pre-resolution pass.
Scope / open questions
- Resolve
$refto other local files (relative paths), not just same-document refs. - Decide how deep the resolution needs to go (just schemas, or also parameters/responses/
requestBodies that live in other files). - Out of scope for this issue: remote (
http(s)://)$refs, unless trivial to support.
Context
- refactor: Enhance OpenAPI code generation with multi-spec support quarkiverse/quarkus-openapi-generator#1599 added the external workaround on the consumer side.
- quarkiverse/quarkus-openapi-generator docs explicitly call out that "Apicurio can generate
from entry specs that use relative$refvalues across multiple YAML or JSON files" — but
that capability lives entirely in the consumer today, not here.
Activity
EricWittmann commentedon Oct 29, 2026
Suggestion: use the dereferencing logic to dereference/normalize the openapi spec into a single document before processing in apitomy-codegen.
Take a look at this: