microsoft / microsoft/OpenAPI.NET

OpenApiVisitorBase PathString is not correct for v2 documents

Đang mở
#2,806 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

@baywet đang làm issue này rồi.

Từ ngày 16/4/2026.

help wanted type:feature
Ngôn ngữ chính
C#
Star
1.6k
Fork
286
Merge trung bình
6 giờ 38 phút
Pull request đã merge (30 ngày)
35

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.