Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`openapi spec lint --fix` drops node-level fixes and can duplicate paths

Đã đóng
#280 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #281 của @RaphaelFakhri — đã merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go, yaml
Lĩnh vực
backend, cli

Hướng nghiên cứu

Start with fix.Engine and the CLI path that writes openapi spec lint --fix output through marshaller.Marshal; compare that sync step with the direct yaml.Marshal used in openapi/linter/rules integration tests. Trace how ApplyNode changes are reconciled with the model, especially renamed path keys. Done means the reproduced fixes survive writing without duplicate paths; linked pull request #281 is already open.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

openapi spec lint --fix reports fixes as applied, but fixes that edit the YAML node tree directly (the validation.NodeFix implementations) are lost when the document is written. Fixes affected include owasp-security-hosts-https-oas3, style-oas3-host-trailing-slash, style-path-trailing-slash, and semantic-duplicated-enum.

For style-path-trailing-slash, the output contains both the fixed path and the original path, so the written document has a duplicated operation.

Steps to reproduce

  1. Save this document as spec.yaml:

    openapi: 3.1.0
    info:
      title: Test
      version: 1.0.0
    servers:
      - url: http://api.example.com/
    paths:
      /pets/:
        get:
          responses:
            "200":
              description: ok
    components:
      schemas:
        E:
          type: string
          enum: [a, b, a]
    
  2. Run openapi spec lint --fix spec.yaml.

Expected result

The written file has url: https://api.example.com, a single /pets path, and enum: [a, b].

Actual result

The command prints Applied 8 fix(es), including the HTTPS upgrade, both trailing-slash fixes, and the duplicate enum fix. The written file still has url: http://api.example.com/ and enum: [a, b, a], and contains both /pets and /pets/. Fixes that edit the model, such as the added error responses, are kept and appear under both paths.

Cause

fix.Engine calls ApplyNode on the document root node. The CLI then writes the document with marshaller.Marshal, which syncs the high-level model back over the nodes. The model still holds the original values, so value edits are reverted, and the original path key is added back next to the renamed key node.

The fix integration tests in openapi/linter/rules encode the root node with yaml.Marshal directly, so they do not run the sync step that the CLI uses.

Ngôn ngữ chính
Go
Star
276
Fork
21
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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.

Issue tương tự

Thêm issue về Go

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.