null property should be ignored (#886)

* null property should be ignored

* check null value
This commit is contained in:
xiaoxu qi 2022-10-24 11:32:32 +08:00 коммит произвёл GitHub
Родитель 22a5175ace
Коммит c2f67e1431
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 31 добавлений и 3 удалений

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

@ -52,7 +52,8 @@ export function diffRequestResponse(
if (!isReplace) {
return buildLiveValidationIssue("ROUNDTRIP_INCONSISTENT_PROPERTY", jsonPath, it);
}
} else if (it.add !== undefined) {
} else if (it.add !== undefined && it.value !== null) {
// IF a property is not in request but returned in response as null, ignore.
const isReadOnly =
operationLoader.attrChecker(
path,
@ -112,7 +113,11 @@ export function buildLiveValidationIssue(
it: any
): LiveValidationIssue {
let severity, message;
const property = path.split("/").pop();
const properties = path.split("/");
let property = properties.pop();
if (!isNaN(Number(property)) && properties.length > 0) {
property = `${properties.pop()}/${property}`;
}
switch (errorCode) {
case "ROUNDTRIP_INCONSISTENT_PROPERTY": {
severity = roundTripValidationErrors.ROUNDTRIP_INCONSISTENT_PROPERTY.severity;

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

@ -66,6 +66,23 @@ Object {
"url": "",
},
},
Object {
"code": "ROUNDTRIP_ADDITIONAL_PROPERTY",
"jsonPathsInPayload": Array [],
"message": "The property 'versionlist/1' is returned in the GET response, but it is not declared in the PUT request.",
"pathsInPayload": Array [
"/versionlist/1",
],
"schemaPath": "",
"severity": 0,
"source": Object {
"position": Object {
"column": 0,
"line": 0,
},
"url": "",
},
},
Object {
"code": "ROUNDTRIP_MISSING_PROPERTY",
"jsonPathsInPayload": Array [],

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

@ -16,6 +16,7 @@
},
"body": {
"location": "westcentralus",
"versionlist":["v1"],
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A2_v3"
@ -73,6 +74,11 @@
"hardwareProfile": {
"vmSize": "Standard_A2_v2"
},
"osversion": null,
"versionlist": [
"v1",
"v2"
],
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A2_v2"

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

@ -144,7 +144,7 @@ describe("Live Validator", () => {
const payload: RequestResponsePair = require(`${__dirname}/liveValidation/payloads/roundTrip_invalid.json`);
const rest = await validator.validateRoundTrip(payload);
expect(rest).toMatchSnapshot();
assert.equal(rest.errors.length, 6);
assert.equal(rest.errors.length, 7);
assert.equal(rest.isSuccessful, false);
for (const re of rest.errors) {
if (re.pathsInPayload[0].includes("location")) {