`openapi spec lint --fix` drops node-level fixes and can duplicate paths
Mantenedores costumam responder em até 1 dia
Um pull request relacionado já foi integrado.
- #281 de @RaphaelFakhri — integrado
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Go
- Estrelas
- 276
- Forks
- 21
- Merge médio
- 1d 6h
- PRs com merge (30d)
- 23
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 2 dias
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
cli/cli#14895 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
kagent-dev/kagent#3462 ·
Mantenedores costumam responder em até 1 dia
-
netrc credential source accepts a password with an embedded CR/LF that every other source rejectsAbertaagent-butler-finding bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
jordansmall/spindrift#6268 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 7 dias