Ignore unknown formats in AJV (#910)
* Ignore unknown formats in AJV * Added testing spec * Updated test
This commit is contained in:
Родитель
6b269336ce
Коммит
e96760fd6a
|
@ -1,5 +1,9 @@
|
|||
# Change Log - oav
|
||||
|
||||
## 11/23/2022 3.2.3
|
||||
|
||||
- AjvSchemaValidator - Ignore unknown format when compile schema
|
||||
|
||||
## 11/07/2022 3.2.2
|
||||
|
||||
- API Scenario
|
||||
|
|
|
@ -51,6 +51,7 @@ export class AjvSchemaValidator implements SchemaValidator {
|
|||
inlineRefs: false,
|
||||
passContext: true,
|
||||
loopRequired: 2,
|
||||
unknownFormats: "ignore",
|
||||
loadSchema: async (uri) => {
|
||||
const spec: SwaggerSpec = await loader.resolveFile(uri);
|
||||
return { [$id]: spec[$id], definitions: spec.definitions, parameters: spec.parameters };
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "oav",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "oav",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@autorest/schemas": "^1.3.4",
|
||||
|
@ -88,7 +88,7 @@
|
|||
"typescript": "^3.9.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.11.0"
|
||||
"node": ">=16.18.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oav",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.3",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation",
|
||||
"email": "azsdkteam@microsoft.com",
|
||||
|
@ -131,9 +131,9 @@
|
|||
"li": "npm install @ts-common/local-install --no-save && local-install"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.11.0"
|
||||
"node": ">=16.18.1"
|
||||
},
|
||||
"jest-junit": {
|
||||
"output": "test-results.xml"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -192,7 +192,8 @@
|
|||
"properties": {
|
||||
"firstName": {
|
||||
"type": "string",
|
||||
"description": "First name."
|
||||
"description": "First name.",
|
||||
"format": "unknown format"
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "title",
|
||||
"description": "",
|
||||
"version": "2022-11-23"
|
||||
},
|
||||
"host": "host",
|
||||
"schemes": [
|
||||
"https"
|
||||
],
|
||||
"paths": {
|
||||
"/hello": {
|
||||
"get": {
|
||||
"operationId": "Resource_Create",
|
||||
"description": "Test operation",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"model": {
|
||||
"type": "string",
|
||||
"format": "unknown format"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -147,6 +147,11 @@ describe("Semantic validation", () => {
|
|||
"Failed to compile validator on operation"
|
||||
);
|
||||
});
|
||||
it("should ignore unknown format when compile schema", async () => {
|
||||
const specPath = `${testPath}/semanticValidation/specification/validateCompile/Swagger-with-unknown-format.json`;
|
||||
const result = await validate.validateSpec(specPath, undefined);
|
||||
assert(result.validityStatus === true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("validateDiscriminator", () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче