OpenAPITools / OpenAPITools/openapi-diff

Unify Handling of allOf/anyOf and oneOf in Diff logic

Ouverte
#772 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

enhancement
Langage dominant
Java
Étoiles
1.1k
Forks
190
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par SchemaDiff#resolveComposedSchema et SchemaDiff#addSchema pour comprendre comment allOf/anyOf sont aplatis, puis consultez ComposedSchemaDiffResult#diff et ChangedOneOfSchema pour la comparaison existante de oneOf. Définissez comment les ajouts, suppressions et modifications structurels dans allOf/anyOf doivent apparaître aux côtés des changements de propriétés aplatis ; le travail est terminé lorsque le diff signale les changements de composition de manière cohérente sans perdre de détails pertinents.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
api
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.