Filter unused OpenAPI definitions when extracting selected operations

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
openapi, typescript
Ambito
cli, tooling

Direzione di ricerca

Start at the apiops extract command in the TypeScript CLI source and trace where the --filter operation selection prunes paths before the spec is written to specification.yaml. The fix belongs after paths are filtered: collect the $ref targets reachable from the remaining operations and keep only those components/definitions, walking transitively so shared schemas and nested items survive. Validate with an extracted spec containing an invalid definition used only by an excluded operation, then run it through Spectral — done means Spectral no longer reports errors from unreferenced definitions.

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

Descrizione

type:bug
Command that triggered the bug

apiops extract

Expected behavior

When extracting an API with an operation filter, the generated OpenAPI specification contains only the selected operations, but retains definitions used exclusively by excluded operations.

This can cause validation to fail on an unrelated definition. For example, Spectral reports an array-items error for an invalid schema even when the operation using it was excluded.

Expected behavior

Filter the definitions to those needed by the selected operations, while preserving all transitively referenced components.

Actual behavior

The extractor removes unselected operations from specification.yaml, but still extracts definitions that are not referenced by the selected operations. As a result, validation can fail on an invalid definition unrelated to the selected operations.

apiops CLI version

1.0.5

Environment details

Environment

APIOps CLI: 1.0.5
Command: apiops extract --filter
CI: Azure DevOps with Spectral validation

CI/CD environment

None

Is this bug blocking you?

Yes

Lingua principale
TypeScript
Stelle
44
Fork
14
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 Azure/apiops-cli

Tutte le issue di Azure/apiops-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.