microsoft / microsoft/OpenAPI.NET
OpenApiVisitorBase PathString is not correct for v2 documents
@baywet 已经在做这个了。
开始于 2026年4月16日。
- 主要语言
- C#
- 星标
- 1.6k
- 派生
- 286
- 平均合并
- 6 小时 38 分钟
- 30 天内合并 PR
- 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
ValidateSchemaPropertyHasValuerule.
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。