OpenAPITools / OpenAPITools/openapi-diff

Unify Handling of allOf/anyOf and oneOf in Diff logic

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

Nessuno ha ancora preso questa issue.

enhancement
Lingua principale
Java
Stelle
1.1k
Fork
190
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Current Behavior:

The diffing mechanism currently handles allOf/anyOf and oneOf differently within composed schemas:

  1. allOf/anyOf: These schemas are recursively resolved and their properties are merged into the parent schema before the main diffing occurs. This happens in SchemaDiff#resolveComposedSchema, where properties from allOf/anyOf subschemas are added to the parent using SchemaDiff#addSchema. The original allOf/anyOf structure is effectively flattened.

  2. oneOf: These schemas are not merged beforehand. Instead, the ComposedSchemaDiffResult#diff method performs a structural comparison of the oneOf lists between the old and new schemas. It identifies added, removed, or changed oneOf options, storing the results in a ChangedOneOfSchema object which is then attached to the ChangedSchema.

Suggested Behavior:

This difference in processing leads to an inconsistency. While the merging for allOf/anyOf simplifies property comparison later, it loses the structural information about changes within the allOf/anyOf lists. Conversely, oneOf retains this structural information because it's crucial for understanding changes in available options.

Consider unifying the approach. Perhaps allOf/anyOf could also be compared structurally, similar to oneOf, to provide a more consistent and potentially more informative diff result regarding the composition itself, rather than just the flattened outcome. This would allow tracking additions, removals, or modifications within allOf/anyOf lists directly.

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Inizia da SchemaDiff#resolveComposedSchema e SchemaDiff#addSchema per capire come vengono appiattiti allOf/anyOf, poi leggi ComposedSchemaDiffResult#diff e ChangedOneOfSchema per il confronto esistente di oneOf. Definisci come devono apparire le aggiunte, le rimozioni e le modifiche strutturali in allOf/anyOf insieme alle modifiche delle proprietà appiattite; il lavoro è completato quando il diff segnala in modo coerente le modifiche alla composizione senza perdere dettagli rilevanti.

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

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.