Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[BUG] Cannot parse OpenAPI 3.1 specs using $dynamicRef / $dynamicAnchor (blocked by swagger-parser)

オープン
#12,731 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
openapi, typescript
領域
api, tooling

調査の方向性

まず、提供された Docker コマンドを fixture recursive-category-tree.yaml に対して実行し、生成された typescript-fetch の出力を調べます。swagger-parser PR #2332 と swagger-codegen が使用する依存関係パスを確認し、その後、$dynamicRef、$dynamicAnchor、$defs がどのようにコード生成へ到達するかを追跡します。パーサーの更新が利用可能になり、これらの fixture が any や空のインターフェースではなく具体的な型を生成すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Summary

Swagger Codegen v3 fails to produce meaningful types for OpenAPI 3.1 specs that use $dynamicRef / $dynamicAnchor. Schemas containing $dynamicAnchor result in empty interfaces or any types because swagger-parser does not preserve these fields through the parse/dereference cycle.

Reproduction

Minimal fixtures demonstrating the issue:

docker run --rm \
  -v $(pwd)/recursive-category-tree.yaml:/spec.json \
  swaggerapi/swagger-codegen-cli-v3 generate \
  -i /spec.json -l typescript-fetch -o /out

Result: interface PaginatedUserResponse {} — empty interface, all type information lost.

Root Cause

The failure originates in swagger-parser (shared dependency with OpenAPI Generator). The OAS 3.1 dereferencer:

  1. Crashes when component schemas have both $id and $ref (resolves #/components/schemas/... against the $id URI instead of the document root)
  2. Loses $dynamicRef, $dynamicAnchor, and $defs during the dereference cycle
  3. Does not traverse $defs sub-schemas

A fix PR is open: https://github.com/swagger-api/swagger-parser/pull/2332

Expected Behavior

After the swagger-parser fix is merged and swagger-codegen updates its dependency:

  1. Specs with $dynamicRef / $dynamicAnchor should parse without errors.
  2. The codegen layer should then be updated to resolve $dynamicRef to concrete types instead of emitting any or empty interfaces.

Blocking Dependency

Compatibility Evidence

A cross-generator compatibility matrix is tracked at:
https://github.com/aqeelat/openapi-dynamicref-adoption-tracker


This issue was drafted with assistance from AI tooling. The submitter is responsible for reviewing and validating the contents before submission.

主要言語
Mustache
スター
17.8k
フォーク
5.9k
平均マージ
7時間 9分
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

swagger-api/swagger-codegen のほかの issue

swagger-api/swagger-codegen の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。