Replacing `oneOf` with `anyOf`.

This commit is contained in:
Sergey Shandar 2018-06-19 16:28:53 -07:00
Родитель d549cfcd57
Коммит 9b527592e8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1C1B75FAA0B9B3C8
4 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -1,3 +1,7 @@
### 06/19/2018 0.4.49
- Bug fix: Data is valid against more than one schema from `oneOf` [#248](https://github.com/Azure/oav/pull/248)
The problem occurs when referenced model may also accept `null`. The fix is replacing `oneOf` with `anyOf`.
### 05/14/2018 0.4.38
- Bug fix: `oav extract-xmsexamples` also extracts request headers. [#241](https://github.com/Azure/oav/pull/241)
- Bug fix: x-ms-parametrized-host is not validated correctly [#240](https://github.com/Azure/oav/issues/240)

Просмотреть файл

@ -559,11 +559,12 @@ export interface Model {
additionalProperties?: Model|false
"x-nullable"?: Unknown
in?: Unknown
oneOf?: Unknown
oneOf?: Model[]
$ref?: string
required?: Unknown[]|false
schema?: Model
allOf?: Ref[]
anyOf?: Model[]
description?: Unknown
discriminator?: string
"x-ms-discriminator-value"?: string
@ -698,8 +699,9 @@ export function allowNullType(entity: Model, isPropRequired?: boolean|{}): Model
&& entity.$ref
&& shouldAcceptNullValue(entity["x-nullable"], isPropRequired)) {
const savedEntity = entity
entity = {}
entity.oneOf = [savedEntity, { type: "null" }]
entity = {
anyOf: [savedEntity, { type: "null" }]
}
}
return entity
}

10
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "oav",
"version": "0.4.48",
"version": "0.4.49",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -5663,9 +5663,9 @@
}
},
"validator": {
"version": "10.3.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-10.3.0.tgz",
"integrity": "sha512-bn7dcJcdkpSjcujYlf8lrY9VL660h5njEkFzQzQOFMQgJ3Id1C4+MkazHKgHE45NoGsyQYEPmo4dCIbDQ7eTdw=="
"version": "10.4.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-10.4.0.tgz",
"integrity": "sha512-Q/wBy3LB1uOyssgNlXSRmaf22NxjvDNZM2MtIQ4jaEOAB61xsh1TQxsq1CgzUMBV1lDrVMogIh8GjG1DYW0zLg=="
},
"z-schema": {
"version": "3.22.0",
@ -5675,7 +5675,7 @@
"commander": "2.15.0",
"lodash.get": "4.4.2",
"lodash.isequal": "4.5.0",
"validator": "10.3.0"
"validator": "10.4.0"
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "oav",
"version": "0.4.48",
"version": "0.4.49",
"author": {
"name": "Microsoft Corporation",
"email": "azsdkteam@microsoft.com",