Get real schema and data while error's schema has allOf property (#798)

This commit is contained in:
Ke Yu 2022-05-16 17:31:46 +08:00 коммит произвёл GitHub
Родитель 48a1a72ec3
Коммит dff4f111c4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 42 добавлений и 6 удалений

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

@ -1,5 +1,9 @@
# Change Log - oav
## 04/20/2022 2.12.2
- LiveValidator - Get real schema and data while error's schema has allOf property
## 04/20/2022 2.12.1
- Fix bug about copyfiles command during build

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

@ -272,8 +272,13 @@ const ReValidateIfNeed = (
};
const shouldSkipError = (error: ErrorObject, cxt: SchemaValidateContext) => {
const { schema, parentSchema: parentSch, params, keyword, data } = error;
const { parentSchema: parentSch, params, keyword } = error;
const parentSchema = parentSch as Schema;
// If schema has allof property, we can get schema in "_realschema", so is data
const schema = Object.keys(error).includes("_realSchema")
? (error as any)._realSchema
: error.schema;
const data = Object.keys(error).includes("_realData") ? (error as any)._realData : error.data;
if (schema?._skipError || parentSchema._skipError) {
return true;

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

@ -1,12 +1,12 @@
{
"name": "oav",
"version": "2.12.1",
"version": "2.12.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "oav",
"version": "2.12.1",
"version": "2.12.2",
"license": "MIT",
"dependencies": {
"@autorest/schemas": "^1.3.1",

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

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

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

@ -74,7 +74,9 @@
"validationEnvironment": false,
"ring": null,
"registrationInfo": {
"timeType": "RemindDueDate",
"expirationTime": "2024-02-29T02:33:35",
"remindTime": "2024-01-29T02:33:35",
"token": "a",
"registrationTokenOperation": "Update"
},

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

@ -474,10 +474,34 @@
}
}
},
"RemindDueDate": {
"description": "Remind the due date of registration.",
"type": "object",
"allOf": [
{
"$ref": "#/definitions/RegistrationInfo"
}
],
"properties": {
"remindTime": {
"format": "date-time",
"type": "string",
"description": "Remind time of registration due date."
}
},
"x-ms-discriminator-value": "RemindDueDate"
},
"RegistrationInfo": {
"description": "Represents a RegistrationInfo definition.",
"type": "object",
"required": [
"timeType"
],
"properties": {
"timeType": {
"description": "Type of time.",
"type": "string"
},
"expirationTime": {
"format": "date-time",
"type": "string",
@ -501,7 +525,8 @@
"description": "The type of resetting the token.",
"x-nullable": false
}
}
},
"discriminator": "timeType"
},
"MigrationRequestProperties": {
"type": "object",

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

@ -1037,7 +1037,7 @@ describe("Live Validator", () => {
isPathCaseSensitive: false,
useRelativeSourceLocationUrl: true,
swaggerPathsPattern: [
"specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/*.json",
"specification/date-time/resource-manager/Microsoft.DateTime/test.json",
],
git: {
shouldClone: false,