`openapi spec lint --fix` drops node-level fixes and can duplicate paths
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
-
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] -
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.
- 主要言語
- Go
- スター
- 276
- フォーク
- 21
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 20
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
speakeasy-api/openapi のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
speakeasy-api/openapi#289 ·
メンテナーはふだん 1 日以内に返信
speakeasy-api/openapi の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
cloudevents/sdk-go#1346 ·
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
kubernetes/cloud-provider-aws#1517 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
agent-butler-finding chore
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
jordansmall/spindrift#6221 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 3 日以内に返信