[Bug]: content.examples $ref not resolved in request bodies or parameters
評価
調査の方向性
まず、ParseOptions の resolve と resolveFully を有効にして、示されている request-body と parameter の例を使用し、OpenAPIParser.readContents で問題を再現します。パーサーが content の例をどのように処理するかを追跡し、両方の場所を比較します。完了条件は、解析された OpenAPI の結果で各 example 参照が参照先の example データに置き換えられ、両方のケースに対する回帰テストのカバレッジがあることです。
索引モデルが issue の本文から書いたものです。
説明
Description
When using resolveFully(true) to parse OpenAPI 3.0.x specs, $ref pointers within content.examples (in request bodies and parameters) are not resolved. The $ref remains as a pointer instead of being replaced with the referenced example.
Affected Version
- 2.1.36
Steps to Reproduce
You can reproduce this issue by passing in an Open API 3.0.x spec with content examples into a parser with resolve options enabled.
String spec = """
{
"openapi": "3.0.3",
"info": {
"title": "Example Reference Demo API",
"version": "1.0"
},
"paths": {
"/users": {
"post": {
"summary": "Create a user",
"parameters": [
{
"name": "filter",
"in": "query",
"content": {
"application/json": {
"schema": {
"type": "object"
},
"examples": {
"simpleFilter": {
"$ref": "#/components/examples/FilterExample"
}
}
}
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"defaultUser": {
"$ref": "#/components/examples/UserExample"
}
}
}
}
},
"responses": {
"201": {
"description": "Created"
}
}
}
}
},
"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"examples": {
"UserExample": {
"summary": "A sample user",
"value": {
"id": "12345",
"name": "John Doe"
}
},
"FilterExample": {
"summary": "A sample filter",
"value": {
"status": "active"
}
}
}
}
}
""";
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(true);
SwaggerParseResult openAPIresult = new OpenAPIParser().readContents(spec, null, options);
OpenAPI result = openAPIResult.getOpenAPI();
System.out.println("OpenAPI result: " + result);
Expected Behavior
Content examples are resolved:
{
"paths": {
"/users": {
"post": {
"summary": "Create a user",
"parameters": [
{
"name": "filter",
"in": "query",
"content": {
"application/json": {
"schema": { "type": "object" },
"examples": {
"simpleFilter": {
"summary": "A sample filter",
"value": { "status": "active" }
}
}
}
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" }
}
},
"examples": {
"defaultUser": {
"summary": "A sample user",
"value": { "id": "12345", "name": "John Doe" }
}
}
}
}
},
"responses": { "201": { "description": "Created" } }
}
}
}
}
Actual Behavior
Content examples remain as $ref pointers:
{
"paths": {
"/users": {
"post": {
"summary": "Create a user",
"parameters": [
{
"name": "filter",
"in": "query",
"content": {
"application/json": {
"schema": { "type": "object" },
"examples": {
"simpleFilter": {
"$ref": "#/components/examples/FilterExample"
}
}
}
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" }
}
},
"examples": {
"defaultUser": {
"$ref": "#/components/examples/UserExample"
}
}
}
}
},
"responses": { "201": { "description": "Created" } }
}
}
}
}
Logs / Stack Traces
N/A
Environment
- Java version: 21
- Build tool: Maven 3.9
- OS: macOS
Additional Context
N/A
Checklist
- I have searched the existing issues and this is not a duplicate.
- I have provided sufficient information for maintainers to reproduce the issue.
- 主要言語
- Java
- スター
- 868
- フォーク
- 560
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
swagger-api/swagger-parser のほかの issue
-
InlineModelResolver.uniqueName throws StringIndexOutOfBoundsException for titles starting with a separator (camelCaseFlattenNaming)対応中かも @arimu1 が 40 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
swagger-api/swagger-parser#2386 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
swagger-api/swagger-parser#2168 ·
-
ResolveFully fails on internal references when the initial spec is read from a file URL対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
swagger-api/swagger-parser#1922 · コメント 2 件 · リアクション 1 件 ·
-
[Bug]: `ResolverFully` does not process OAS 3.1 combinators and skips nested OAS 3.1 schema-valued keywords対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンBug
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
swagger-api/swagger-parser#2403 ·
-
[Bug]: Regression: resolveFully fails when components key does not match external file basename対応中かも @goutamadwant が 33 日前に担当しました。 オープンBug
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
swagger-api/swagger-parser#2399 · コメント 3 件 ·
swagger-api/swagger-parser の issue をすべて見る
似ている issue
-
GeminiUtil placeholder user turn ("Continue output. DO NOT look at this line ...") is flagged by prompt injection filters対応中かも @innoprej が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
salesforce/multicloudj#667 ·
メンテナーはふだん 1 日以内に返信
-
Add Zammad対応中かも @Arslan-TR が今日担当しました。 オープンrequest
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
endoflife-date/endoflife.date#11298 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
electron tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信