Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#280 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@RaphaelFakhri ci sta già lavorando.

Dal 24/10/2026.

  • #281 di @RaphaelFakhri — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
go, yaml
Ambito
backend, cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
276
Fork
21
Merge medio
1g 5h
PR unite (30g)
20

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di speakeasy-api/openapi

Tutte le issue di speakeasy-api/openapi

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.