OpenAPITools / OpenAPITools/openapi-diff

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

Abierto
#910 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug OpenAP 3.1.0 Support
Lenguaje dominante
Java
Estrellas
1.1k
Forks
190
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en OpenApiCompare.fromContents y fromSpecifications, utilizando la reproducción proporcionada old.yaml/new.yaml con ParseOptions.setResolveFully(true). Rastrea cómo ChangedOpenApi registra los cambios en los schemas referenciados y dónde se comparan Schema.getType()/getTypes(). Se considera terminado cuando el cambio de weight de integer a string produce un resultado changedOperations o changedSchemas no vacío con una entrada INCOMPATIBLE, mientras que los cambios en required y enum siguen detectándose.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
api, backend-api-design
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bien especificado
Aptitud para principiantes
68/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.