OpenAPITools / OpenAPITools/openapi-diff

Property `type` change on referenced component schema is silently ignored

Aperta
#910 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug OpenAP 3.1.0 Support
Lingua principale
Java
Stelle
1.1k
Fork
190
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Library version: org.openapitools.openapidiff:openapi-diff-core:2.1.7
Java: 21
OpenAPI version of test specs: 3.1.0 (also reproduces on 3.0.x)

Summary

When the only difference between two specs is a type change on a property of a referenced component schema, OpenApiCompare.fromContents reports zero changes. Both getChangedOperations() and getChangedSchemas() are empty. Other property-level changes (required list deltas, enum value deltas) on the same referenced schema are detected normally — only type swaps are dropped.

Minimal reproduction

old.yaml:

openapi: 3.1.0
info:
  title: t
  version: '1'
paths:
  /widgets:
    get:
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Widget'
components:
  schemas:
    Widget:
      type: object
      properties:
        weight:
          type: integer

new.yaml — identical except for weight.type:

openapi: 3.1.0
info:
  title: t
  version: '1'
paths:
  /widgets:
    get:
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Widget'
components:
  schemas:
    Widget:
      type: object
      properties:
        weight:
          type: string
import org.openapitools.openapidiff.core.OpenApiCompare;
import org.openapitools.openapidiff.core.model.ChangedOpenApi;
import java.nio.file.*;

public class Repro {
    public static void main(String[] a) throws Exception {
        String prev = Files.readString(Path.of("old.yaml"));
        String curr = Files.readString(Path.of("new.yaml"));
        ChangedOpenApi d = OpenApiCompare.fromContents(prev, curr);
        System.out.println("missingEndpoints: " + d.getMissingEndpoints().size());
        System.out.println("newEndpoints:     " + d.getNewEndpoints().size());
        System.out.println("changedOperations:" + d.getChangedOperations().size());
        System.out.println("changedSchemas:   " + d.getChangedSchemas().size());
    }
}
Actual output
missingEndpoints: 0
newEndpoints:     0
changedOperations:0
changedSchemas:   0
Expected output

A non-empty changedOperations (or changedSchemas) containing an INCOMPATIBLE entry for the property weight on Widget.

Other findings
  • Reproduces with OpenAPIParser + ParseOptions.setResolveFully(true) and OpenApiCompare.fromSpecifications(...).
  • Inverting the spec versions (3.1.0 ↔ 3.0.3) does not change the result.
  • The same fixture with a required: list change instead (e.g. adding weight to required) is detected correctly — changedOperations and changedSchemas are populated. So the parser does diff the referenced schema; only the type field is being skipped.
  • As a workaround, walking the resolved Schema tree manually after setResolveFully(true) and comparing Schema.getType() / Schema.getTypes() recovers the change.

Happy to put up a PR if pointers to where the schema-type comparator lives would help.

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 OpenApiCompare.fromContents e fromSpecifications, utilizzando la riproduzione old.yaml/new.yaml fornita con ParseOptions.setResolveFully(true). Traccia come ChangedOpenApi registra le modifiche agli schema referenziati e dove vengono confrontati Schema.getType()/getTypes(). Il lavoro è completato quando la modifica di weight da integer a string produce un risultato changedOperations o changedSchemas non vuoto con una voce INCOMPATIBLE, mentre le modifiche a required ed enum continuano a essere rilevate.

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

Valutazione

Stack tecnologico
java
Ambito
api, backend-api-design
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
68/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.