Azure / Azure/azure-openapi-validator

Linter must reject allOf that contain overlapping properties with different types

Open
#252 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
53
Forks
57
Avg merge
1d 23h
Merged PRs (30d)
2

Description

See the below examples. In both cases, the `version` property is duplicated with different types. From discussion with @johanste
>What you describe below is valid swagger, but very unlikely what the author intended. It effectively says that there cannot be a “version” key in the response (the value of any “version” attribute has to be both an integer and a string at the same time, which is impossible). If the authors expectation was that version could be a string *or* an integer, then the swagger is incorrect, and it is a prime example of why we introduced x-ms-examples (the author would have provided what they think is a valid payload, and our tooling would have said “I’m sorry, human, what you are trying to do is wrong. Your understanding of swagger is incomplete.”).

Example 1
```json
"ExtendedProductProperties": {
"description": "Product information.",
"type": "object",
"properties": {},
"allOf": [
{
"$ref": "#/definitions/VirtualMachineExtensionProductProperties"
},
{
"$ref": "#/definitions/VirtualMachineProductProperties"
}
]
},
"VirtualMachineExtensionProductProperties": {
"description": "Product information.",
"type": "object",
"properties": {
"version": {
"description": "Specifies product version.",
"type": "integer",
"format": "int32",
"readOnly": true
}
}
},
"VirtualMachineProductProperties": {
"description": "Product information.",
"type": "object",
"properties": {
"version": {
"description": "Specifies product version.",
"type": "string",
"readOnly": true
}
}
},
```
Example 2
```json
"ExtendedProductProperties": {
"description": "Product information.",
"type": "object",
"properties": {
"version": {
"description": "Specifies product version.",
"type": "integer",
"format": "int32",
"readOnly": true
}
},
"allOf": [
{
"$ref": "#/definitions/VirtualMachineProductProperties"
}
]
},
"VirtualMachineProductProperties": {
"description": "Product information.",
"type": "object",
"properties": {
"version": {
"description": "Specifies product version.",
"type": "string",
"readOnly": true
}
}
},
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.