Repro of #248
This commit is contained in:
Родитель
661845b4e9
Коммит
0270bc91a2
|
@ -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`
|
||||
|
|
Загрузка…
Ссылка в новой задаче