microsoft / microsoft/OpenAPI.NET

OpenApiVisitorBase PathString is not correct for v2 documents

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

@baywet がすでに取り組んでいます。

2026年4月16日 から。

help wanted type:feature
主要言語
C#
スター
1.6k
フォーク
286
平均マージ
6時間 38分
マージ済み PR(30日)
35

説明

Describe the bug
The OpenApiVisitorBase.PathString is documented as 'Pointer to source of validation error in document', but when used with OpenApiWalker and the built-in validation system, it does not produce correct pointers when the input document is in the v2 format. This is because the walker operates on the shared data model which mirrors the v3 structure - which has already been manipulated by the v2 reader.

OpenApi File To Reproduce

{
    "swagger": "2.0",
    "info": {
        "title": "Test API",
        "version": "1.0.0"
    },
    "paths": {
        "/items": {
            "get": {
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "integer"
                                },
                                "name": null
                            }
                        }
                    }
                }
            }
        }
    }
}

Expected behavior
I'd expect a validation error with the pointer:
#/paths/~1items/get/responses/200/schema/properties/name

Instead, we see a validation error with the pointer:
#/paths/~1items/get/responses/200/content/application~1octet-stream/schema/name

This example actually has two separate bugs in one:

  • It looks like a v3 pointer - the 'content/application~1octet-stream' is not present in the document.
  • It is also missing 'properties' path segment due to a bug in the ValidateSchemaPropertyHasValue rule.

Additional context
Ideally it seems like we need the walker to 'undo' the changes that the v2 reader makes to the structure so it can track what the pointer in the underlying document actually is.

At minimum we should document that the PathString is a path to the internal document representation, and not the original document - but IMO it's more useful to have a path to the location in the input document.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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