This commit is contained in:
Sergey Shandar 2018-06-19 12:23:45 -07:00
Родитель 661845b4e9
Коммит 0270bc91a2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1C1B75FAA0B9B3C8
4 изменённых файлов: 47 добавлений и 5 удалений

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

@ -3,9 +3,6 @@
import * as fs from "fs"
import * as path from "path"
import * as msrest from "ms-rest"
import * as msrestazure from "ms-rest-azure"
import { ResourceManagementClient } from "azure-arm-resource"
import { log } from "./util/logging"
import * as utils from "./util/utils"
import { SpecValidator, SpecValidationResult } from "./validators/specValidator"
@ -81,7 +78,6 @@ export async function validateSpec(specPath: string, options: Options|undefined)
try {
await validator.initialize()
log.info(`Semantically validating ${specPath}:\n`)
const result = await validator.validateSpec()
updateEndResultOfSingleValidation(validator)
logDetailedInfo(validator)
return validator.specValidationResult

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

@ -0,0 +1,11 @@
{
"parameters": {},
"responses": {
"200": {
"headers": {},
"body": {
"namedProp": null
}
}
}
}

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

@ -314,6 +314,29 @@
}
}
},
"/foo/definitionWithReferenceNullOperation": {
"get": {
"tags": [
"getTag"
],
"operationId": "definitionWithReferenceNull_Get",
"description": "Operation to test invalid_type for nulls",
"x-ms-examples": {
"required prop operation": {
"$ref": "./examples/definitionWithReferenceNullOperation.json"
}
},
"parameters": [],
"responses": {
"200": {
"description": "success response",
"schema": {
"$ref": "#/definitions/DefinitionWithReference"
}
}
}
}
},
"/foo/definitionWithReferenceNotNullableOperation": {
"get": {
"tags": [
@ -389,7 +412,7 @@
},
"definitions": {
"Result": {
"description": "Result decription",
"description": "Result description",
"properties": {
"prop1": {
"type": "string",

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

@ -329,6 +329,18 @@ describe("Model Validation", () => {
console.log(result)
})
it("should pass for definitionWithReferenceNull_Get", async () => {
const specPath2 =
`${__dirname}/modelValidation/swaggers/specification/nullableTypes/invalid_type_test.json`
const operationIds = "definitionWithReferenceNull_Get"
const result = await validate.validateExamples(
specPath2, operationIds, { consoleLogLevel: "off" })
assert(
result.validityStatus === true,
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`)
console.log(result)
})
it("should pass for definitionWithReferenceNotNullableOperation_Get", async () => {
const specPath2 =
`${__dirname}/modelValidation/swaggers/specification/nullableTypes/invalid_type_test.json`