Update LRO rules for adding allowed response code (#598)
* Update LRO rules for adding allowed response code * Fix style issue
This commit is contained in:
Родитель
40b6b7fa84
Коммит
ab8af58add
|
@ -267,18 +267,23 @@ const validateLroOperation = (
|
|||
result: LiveValidationIssue[]
|
||||
) => {
|
||||
if (operation["x-ms-long-running-operation"] === true) {
|
||||
if (operation._method === "patch" || operation._method === "post") {
|
||||
if (statusCode !== "202" && statusCode !== "201") {
|
||||
result.push(issueFromErrorCode("LRO_RESPONSE_CODE", { statusCode }, operation.responses));
|
||||
} else {
|
||||
if (operation._method === "post") {
|
||||
if (statusCode === "202" || statusCode === "201") {
|
||||
validateLroHeader(operation, headers, result);
|
||||
} else if (statusCode !== "200" && statusCode !== "204") {
|
||||
result.push(issueFromErrorCode("LRO_RESPONSE_CODE", { statusCode }, operation.responses));
|
||||
}
|
||||
} else if (operation._method === "patch") {
|
||||
if (statusCode === "202" || statusCode === "201") {
|
||||
validateLroHeader(operation, headers, result);
|
||||
} else if (statusCode !== "200") {
|
||||
result.push(issueFromErrorCode("LRO_RESPONSE_CODE", { statusCode }, operation.responses));
|
||||
}
|
||||
} else if (operation._method === "delete") {
|
||||
if (statusCode !== "202" && statusCode !== "204") {
|
||||
result.push(issueFromErrorCode("LRO_RESPONSE_CODE", { statusCode }, operation.responses));
|
||||
}
|
||||
if (statusCode === "202") {
|
||||
validateLroHeader(operation, headers, result);
|
||||
} else if (statusCode !== "200" && statusCode !== "204") {
|
||||
result.push(issueFromErrorCode("LRO_RESPONSE_CODE", { statusCode }, operation.responses));
|
||||
}
|
||||
} else if (operation._method === "put") {
|
||||
if (statusCode === "202" || statusCode === "201") {
|
||||
|
|
|
@ -52,7 +52,7 @@ export const validateErrorMessages: { [key in ExtendedErrorCode]?: (params: any)
|
|||
INVALID_RESPONSE_BODY: strTemplate`Body is required in response but not provided`,
|
||||
INVALID_RESPONSE_HEADER: strTemplate`Header ${"missingProperty"} is required in response but not provided`,
|
||||
MISSING_RESOURCE_ID: strTemplate`id is required to return in response of GET/PUT resource calls but not provided`,
|
||||
LRO_RESPONSE_CODE: strTemplate`Patch/Post long running operation must return 201 or 202, Delete long running operation must return 202 or 204, Put long running operation must return 202 or 201 or 200, but ${"statusCode"} returned`,
|
||||
LRO_RESPONSE_CODE: strTemplate`For initial request, Patch/Post long running operation must return 201 or 202, Delete long running operation must return 202 or 204, Put long running operation must return 202 or 201 or 200, but ${"statusCode"} returned`,
|
||||
LRO_RESPONSE_HEADER: strTemplate`Long running operation should return ${"header"} in header but not provided`,
|
||||
|
||||
DISCRIMINATOR_VALUE_NOT_FOUND: strTemplate`Discriminator value "${"data"}" not found`,
|
||||
|
|
|
@ -30,7 +30,7 @@ Object {
|
|||
"jsonRef": "#/definitions/LinkerResource",
|
||||
"position": Object {
|
||||
"column": 23,
|
||||
"line": 566,
|
||||
"line": 572,
|
||||
},
|
||||
"url": "specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-01-01-privatepreview/servicelinker.json",
|
||||
},
|
||||
|
@ -63,7 +63,7 @@ Object {
|
|||
"code": "LRO_RESPONSE_CODE",
|
||||
"documentationUrl": "",
|
||||
"jsonPathsInPayload": Array [],
|
||||
"message": "Patch/Post long running operation must return 201 or 202, Delete long running operation must return 202 or 204, Put long running operation must return 202 or 201 or 200, but 200 returned",
|
||||
"message": "For initial request, Patch/Post long running operation must return 201 or 202, Delete long running operation must return 202 or 204, Put long running operation must return 202 or 201 or 200, but 204 returned",
|
||||
"pathsInPayload": Array [],
|
||||
"schemaPath": "",
|
||||
"severity": 0,
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
}
|
||||
},
|
||||
"liveResponse": {
|
||||
"statusCode": "200",
|
||||
"statusCode": "204",
|
||||
"headers": {
|
||||
"strict-Transport-Security": "max-age=31536000; includeSubDomains",
|
||||
"x-ms-request-id": "97856fec-304a-4317-87f0-f04c328402d3",
|
||||
|
|
|
@ -310,6 +310,12 @@
|
|||
"$ref": "#/definitions/LinkerResource"
|
||||
}
|
||||
},
|
||||
"204": {
|
||||
"description": "Long running operation.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/LinkerResource"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Error response describing why the operation failed.",
|
||||
"schema": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче