`Inline` fails on a recursive schema file shared through a response file: `reference ... not found in analysis phase`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go, openapi
- Domain
- backend-api-design
Research direction
Start by tracing openapi.Inline and the nested reference analysis for external response and schema files; the report does not name implementation or test files. Reproduce with the three operations and recursive Folder.yaml schema, then compare with two operations and a single-file document. Done when the three-operation case inlines successfully for OpenAPI 3.0.3 and 3.1.0, with the recursive reference targeting #/components/schemas/__Folder_yaml.
Written by the indexing model from the issue text.
Description
Summary
openapi.Inline (and openapi spec inline) fails when a self-referencing schema in its own file is reached through a response file that three or more operations reference. With two operations it inlines fine, and so does the same document written in one file.
Reproduction
openapi.yaml:
openapi: 3.0.3
info: {title: t, version: "1"}
paths:
/f1:
get:
responses:
"200": {$ref: ./responses/folder.yaml}
/f2:
get:
responses:
"200": {$ref: ./responses/folder.yaml}
/f3:
get:
responses:
"200": {$ref: ./responses/folder.yaml}
responses/folder.yaml:
description: ok
content: {application/json: {schema: {$ref: ../schemas/Folder.yaml}}}
schemas/Folder.yaml:
properties:
parents:
items: {$ref: ./Folder.yaml}
$ openapi spec inline openapi.yaml
Processing OpenAPI document: openapi.yaml
Error: failed to inline OpenAPI document: failed to inline references: failed to inline nested references in : failed to inline schemas: failed to inline schema: failed to inline schema: reference schemas/Folder.yaml#/components/schemas/__Folder_yaml not found in analysis phase
The library call (openapi.Unmarshal, then openapi.Inline with ResolveOptions{RootDocument: doc, TargetLocation: <absolute path>} and RemoveUnusedComponents: true) returns the same error.
Expected result
The document is inlined, as it is with /f3 removed: each response gets the Folder schema and the recursive ref points at #/components/schemas/__Folder_yaml. The same three operations also inline when they reference ./schemas/Folder.yaml directly, or when the response and the schema are in the root's components (one file).
Actual result
The error above, for openapi: 3.0.3 and 3.1.0 alike, and with four operations too. The reference it can't find, #/components/schemas/__Folder_yaml, is the name the inliner itself gives the recursive schema, here resolved against schemas/Folder.yaml.
Version
v1.26.0 (also main, d269643). CLI from go install github.com/speakeasy-api/openapi/cmd/openapi@latest (v0.0.0-20261016011534-d2696438ec74).
- Dominant language
- Go
- Stars
- 276
- Forks
- 21
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 18
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 speakeasy-api/openapi
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
speakeasy-api/openapi#284 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
speakeasy-api/openapi#283 ·
Maintainers usually reply within 1 day
-
`openapi spec lint --fix` drops node-level fixes and can duplicate pathsPossibly taken @RaphaelFakhri claimed this 4 days ago. Open
Difficulty 4/5 1-2 days Newbie friendliness 35/100
speakeasy-api/openapi#280 ·
Maintainers usually reply within 1 day
All issues in speakeasy-api/openapi
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
agent-butler-finding bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jordansmall/spindrift#6161 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-telemetry/opentelemetry-go-compile-instrumentation#1635 ·
Maintainers usually reply within 2 days
-
C-bug O-community X-blathers-untriaged
Difficulty 1/5 Under an hour Newbie friendliness 84/100
cockroachdb/cockroach#176210 · 1 comment ·
-
VLAgent `spec.k8sCollector.includePodLabels: false` has no effectPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
VictoriaMetrics/operator#2772 ·
Maintainers usually reply within 1 day