Azure / Azure/openapi-diff

Crash if duplicate model names (across files) used in allOf

Abierto
#479 2 comentarios 0 reacciones 1 asignado Reclamado por @mikeharder Ver en GitHub
Lenguaje dominante
C#
Estrellas
290
Forks
50
Merge medio
5 d 13 h
PR fusionados (30 d)
5

Descripción

A TSP conversion PR resulted in this error:

```
"details":"incompatible properties : tags

definitions/ContainerGroup/properties/tags
at file:///home/runner/work/azure-rest-api-specs/azure-rest-api-specs/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/ContainerInstance/stable/2025-09-01/containerInstance.json#L2245:8

definitions/Resource/properties/tags
at file:///home/runner/work/azure-rest-api-specs/azure-rest-api-specs/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/ContainerInstance/stable/2025-09-01/containerInstance.json#L4642:8"
```

- https://github.com/Azure/azure-rest-api-specs/actions/runs/23628050434
- https://github.com/Azure/azure-rest-api-specs/pull/41602

Root cause, oad cannot handle two definitions in different files with the same name, if one definition is used in an `allOf`:

### duplicate-names.json
```json
{
"swagger": "2.0",
"info": {
"title": "duplicate-names",
"version": "1.0"
},
"paths": {},
"definitions": {
"Bar": {
"type": "object",
"properties": {
"p1": {
"type": "string"
}
},
"allOf": [
{
"$ref": "./common-types.json#/definitions/Foo"
}
]
},
"Foo": {
"type": "object",
"properties": {
"p1": {
"type": "object"
}
}
}
}
}
```

### common-types.json
```json
{
"swagger": "2.0",
"info": {
"title": "common-types",
"version": "1.0"
},
"paths": {},
"definitions": {
"Foo": {
"type": "object",
"properties": {
"p1": {
"type": "string"
}
}
}
}
}
```

### test result
```
incompatible properties : p1
definitions/Bar/properties/p1
at file:///home/mharder/openapi-diff-mh/incompat-prop/src/test/specs/incompatible-properties/duplicate-names.json#L12:8
definitions/Foo/properties/p1
at file:///home/mharder/openapi-diff-mh/incompat-prop/src/test/specs/incompatible-properties/duplicate-names.json#L25:8
```

- Test case: https://github.com/Azure/openapi-diff/pull/481

Reason, it assumes model names are unique across all files:

https://github.com/Azure/openapi-diff/blob/bb4653d32f49ceb2abab48656c42c253865697e1/src/lib/util/resolveSwagger.ts#L346-L352

Related: #347

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.