Suppression. No `where` support yet. (#317)
* read markdown file. * suppressions * supression object * Return suppressions * update package-lock. * prettyPrint() function * processErrors() * pass suppression * where is not implemented yet * changelog * TODO: * resolve conflicts * switch back to z-schema * Suppression test * comments
This commit is contained in:
Родитель
b41b253b1b
Коммит
c31480764b
|
@ -98,7 +98,7 @@
|
|||
"stopOnEntry": false,
|
||||
"args": [
|
||||
"--no-timeouts",
|
||||
"test/semanticValidatorTests.ts",
|
||||
"test/modelValidatorTests.ts",
|
||||
"-r",
|
||||
"ts-node/register",
|
||||
"--no-timeouts"
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
### 09/21/2018 0.6.0
|
||||
|
||||
- Suppression. `where` is not supported yet.
|
||||
|
||||
### 09/21/2018 0.5.13
|
||||
|
||||
- Correcting where we add url and position information to semantic validation errors.
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
import { NodeError } from "./validationError"
|
||||
import { forEach, isArray } from "@ts-common/iterator"
|
||||
import { jsonSymbol } from "@ts-common/z-schema"
|
||||
import { getInfo, getRootObjectInfo } from '@ts-common/source-map'
|
||||
import { TitleObject } from '../validators/specTransformer'
|
||||
import { log } from './logging'
|
||||
import { getDescendantFilePosition } from "@ts-common/source-map"
|
||||
|
||||
export const errorsAddFileInfo = <T extends NodeError<T>, E extends Iterable<T>>(
|
||||
errors: E | undefined,
|
||||
): E | undefined => {
|
||||
forEach(errors, errorAddFileInfo)
|
||||
return errors
|
||||
}
|
||||
|
||||
const errorAddFileInfo = <T extends NodeError<T>>(error: T): void => {
|
||||
const title = error.title
|
||||
if (title !== undefined) {
|
||||
try {
|
||||
const titleObject: TitleObject | undefined = JSON.parse(title)
|
||||
if (titleObject !== undefined) {
|
||||
error.position = titleObject.position
|
||||
error.url = titleObject.url
|
||||
error.title = titleObject.title
|
||||
}
|
||||
// tslint:disable-next-line:no-empty
|
||||
} catch {
|
||||
log.error(`ICE: can't parse title: ${title}`)
|
||||
}
|
||||
}
|
||||
const json = error[jsonSymbol]
|
||||
if (json !== undefined) {
|
||||
const jsonInfo = getInfo(json)
|
||||
if (jsonInfo !== undefined) {
|
||||
const path = error.path
|
||||
error.jsonPosition = getDescendantFilePosition(
|
||||
json,
|
||||
path === undefined ? undefined : isArray(path) ? path : path.split("/")
|
||||
)
|
||||
error.jsonUrl = getRootObjectInfo(jsonInfo).url
|
||||
}
|
||||
}
|
||||
errorsAddFileInfo(error.errors)
|
||||
errorsAddFileInfo(error.inner)
|
||||
}
|
|
@ -6,6 +6,7 @@ import { operationReducer } from "./operationReducer"
|
|||
import { OperationResult } from "./scenarioReducer"
|
||||
import * as sm from "@ts-common/string-map"
|
||||
import * as it from "@ts-common/iterator"
|
||||
import { Suppression } from '@ts-common/azure-openapi-markdown';
|
||||
|
||||
export interface ModelValidation {
|
||||
operations: sm.MutableStringMap<OperationResult | undefined>
|
||||
|
@ -15,6 +16,7 @@ export interface ModelValidation {
|
|||
* From the raw validator engine results process errors to be served.
|
||||
*/
|
||||
export function getErrorsFromModelValidation(
|
||||
suppression: Suppression | undefined,
|
||||
validationResult: ModelValidation,
|
||||
): ReadonlyArray<ModelValidationError> {
|
||||
if (!validationResult.operations) {
|
||||
|
@ -35,5 +37,5 @@ export function getErrorsFromModelValidation(
|
|||
}
|
||||
return { operationId, scenarios }
|
||||
})
|
||||
return it.toArray(it.flatMap(operations, operationReducer))
|
||||
return it.toArray(it.flatMap(operations, v => operationReducer(suppression, v)))
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { ModelValidationError } from "./modelValidationError"
|
|||
import { Scenarios } from "./responseReducer"
|
||||
import * as sm from "@ts-common/string-map"
|
||||
import * as it from "@ts-common/iterator"
|
||||
import { Suppression } from '@ts-common/azure-openapi-markdown';
|
||||
|
||||
interface OperationResultScenarios {
|
||||
readonly operationId: string
|
||||
|
@ -13,12 +14,13 @@ interface OperationResultScenarios {
|
|||
}
|
||||
|
||||
export function operationReducer(
|
||||
suppression: Suppression | undefined,
|
||||
{ operationId, scenarios }: OperationResultScenarios,
|
||||
): Iterable<ModelValidationError> {
|
||||
const scenariosEntries = sm.entries(scenarios)
|
||||
const invalidScenarios = it.filter(scenariosEntries, ([_, scenario]) => !scenario.isValid)
|
||||
const result = it.flatMap(
|
||||
invalidScenarios,
|
||||
([scenarioName, scenario]) => scenarioReducer(scenarioName, scenario, operationId))
|
||||
([scenarioName, scenario]) => scenarioReducer(suppression, scenarioName, scenario, operationId))
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { NodeError } from "./validationError"
|
||||
import { isArray, filterMap } from "@ts-common/iterator"
|
||||
import { jsonSymbol } from "z-schema"
|
||||
import { getInfo, getRootObjectInfo } from '@ts-common/source-map'
|
||||
import { TitleObject } from '../validators/specTransformer'
|
||||
import { log } from './logging'
|
||||
import { getDescendantFilePosition } from "@ts-common/source-map"
|
||||
import { Suppression } from '@ts-common/azure-openapi-markdown';
|
||||
|
||||
export const processErrors = <T extends NodeError<T>>(
|
||||
suppression: Suppression | undefined,
|
||||
errors: T[] | undefined,
|
||||
): T[] | undefined =>
|
||||
createErrorProcessor<T>(suppression)(errors)
|
||||
|
||||
const addFileInfo = <T extends NodeError<T>>(error: T): T => {
|
||||
const title = error.title
|
||||
if (title !== undefined) {
|
||||
try {
|
||||
const titleObject: TitleObject | undefined = JSON.parse(title)
|
||||
if (titleObject !== undefined) {
|
||||
error.position = titleObject.position
|
||||
error.url = titleObject.url
|
||||
error.title = titleObject.title
|
||||
}
|
||||
// tslint:disable-next-line:no-empty
|
||||
} catch {
|
||||
log.error(`ICE: can't parse title: ${title}`)
|
||||
}
|
||||
}
|
||||
const json = error[jsonSymbol]
|
||||
if (json !== undefined) {
|
||||
const jsonInfo = getInfo(json)
|
||||
if (jsonInfo !== undefined) {
|
||||
const path = error.path
|
||||
error.jsonPosition = getDescendantFilePosition(
|
||||
json,
|
||||
path === undefined ? undefined : isArray(path) ? path : path.split("/")
|
||||
)
|
||||
error.jsonUrl = getRootObjectInfo(jsonInfo).url
|
||||
}
|
||||
}
|
||||
return error
|
||||
}
|
||||
|
||||
const createErrorProcessor = <T extends NodeError<T>>(suppression: Suppression | undefined) => {
|
||||
|
||||
const isSuppressed = suppression === undefined ?
|
||||
() => false :
|
||||
(error: T): boolean =>
|
||||
// TODO: JSONPath: https://www.npmjs.com/package/jsonpath using jp.nodes() function.
|
||||
// See error codes:
|
||||
// https://github.com/Azure/oav/blob/master/documentation/oav-errors-reference.md#errors-index
|
||||
suppression.directive.some(item => error.code === item.suppress)
|
||||
|
||||
const one = (error: T): T | undefined => {
|
||||
error = addFileInfo(error)
|
||||
if (isSuppressed(error)) {
|
||||
return undefined
|
||||
}
|
||||
error.errors = multiple(error.errors)
|
||||
error.inner = multiple(error.inner)
|
||||
return error
|
||||
}
|
||||
const multiple = (errors: T[] | undefined) =>
|
||||
errors === undefined ? undefined : Array.from(filterMap(errors, one))
|
||||
return multiple
|
||||
}
|
|
@ -6,6 +6,7 @@ import { toModelErrors } from "./toModelErrors"
|
|||
import { ValidationResultSource } from "./validationResultSource"
|
||||
import { ModelValidationError } from "./modelValidationError"
|
||||
import { MutableStringMap } from '@ts-common/string-map';
|
||||
import { Suppression } from '@ts-common/azure-openapi-markdown';
|
||||
|
||||
export interface Result {
|
||||
isValid?: unknown
|
||||
|
@ -27,6 +28,7 @@ export interface Scenario {
|
|||
}
|
||||
|
||||
export function responseReducer(
|
||||
suppression: Suppression | undefined,
|
||||
responseCode: string,
|
||||
scenario: Scenario,
|
||||
rawValidationResult: ValidationResult<ModelValidationError>,
|
||||
|
@ -41,7 +43,7 @@ export function responseReducer(
|
|||
? response.error.innerErrors
|
||||
: []
|
||||
|
||||
const processedErrors = processValidationErrors(rawValidationResult)
|
||||
const processedErrors = processValidationErrors(suppression, rawValidationResult)
|
||||
|
||||
if (processedErrors.responseValidationResult.errors === undefined) {
|
||||
throw new Error("ICE: processedErrors.responseValidationResult.errors === undefined")
|
||||
|
|
|
@ -9,6 +9,7 @@ import { ModelValidationError } from "./modelValidationError"
|
|||
import { CommonError } from "./commonError"
|
||||
import * as sm from "@ts-common/string-map"
|
||||
import * as it from "@ts-common/iterator"
|
||||
import { Suppression } from '@ts-common/azure-openapi-markdown';
|
||||
|
||||
export interface Result {
|
||||
isValid?: unknown
|
||||
|
@ -24,6 +25,7 @@ export type OperationExampleResult = Scenario
|
|||
export type OperationResult = sm.MutableStringMap<OperationExampleResult>
|
||||
|
||||
export function scenarioReducer(
|
||||
suppression: Suppression | undefined,
|
||||
scenarioName: string,
|
||||
scenario: Scenario,
|
||||
operationId: string,
|
||||
|
@ -41,7 +43,7 @@ export function scenarioReducer(
|
|||
}
|
||||
}
|
||||
// process request separately since its unique
|
||||
const processedErrors = processValidationErrors(rawValidationResult);
|
||||
const processedErrors = processValidationErrors(suppression, rawValidationResult);
|
||||
|
||||
if (processedErrors.requestValidationResult.errors === undefined) {
|
||||
throw new Error("ICE: processedErrors.requestValidationResult.errors === undefined")
|
||||
|
@ -61,6 +63,7 @@ export function scenarioReducer(
|
|||
const entries = sm.entries(scenario.responses)
|
||||
const invalidResponses = it.filter(entries, ([_, response]) => !response.isValid)
|
||||
const result = it.flatMap(invalidResponses, ([responseCode]) => responseReducer(
|
||||
suppression,
|
||||
responseCode,
|
||||
scenario,
|
||||
rawValidationResult,
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { Severity } from "./severity"
|
||||
import _ from "lodash"
|
||||
import { FilePosition } from "@ts-common/source-map"
|
||||
import { flatMap, fold } from "@ts-common/iterator"
|
||||
import { errorsAddFileInfo } from "./errorFileInfo"
|
||||
import { jsonSymbol, schemaSymbol } from "@ts-common/z-schema"
|
||||
import { processErrors } from "./processErrors"
|
||||
import { jsonSymbol, schemaSymbol } from "z-schema"
|
||||
import { Suppression } from '@ts-common/azure-openapi-markdown';
|
||||
|
||||
/**
|
||||
* @class
|
||||
|
@ -121,7 +123,10 @@ export interface ValidationResult<T extends NodeError<T>> {
|
|||
export function processValidationErrors<
|
||||
V extends ValidationResult<T>,
|
||||
T extends NodeError<T>
|
||||
>(rawValidation: V): V {
|
||||
>(
|
||||
suppression: Suppression | undefined,
|
||||
rawValidation: V
|
||||
): V {
|
||||
const requestSerializedErrors: T[] = serializeErrors(
|
||||
rawValidation.requestValidationResult,
|
||||
[]
|
||||
|
@ -131,8 +136,14 @@ export function processValidationErrors<
|
|||
[]
|
||||
)
|
||||
|
||||
rawValidation.requestValidationResult.errors = errorsAddFileInfo(requestSerializedErrors)
|
||||
rawValidation.responseValidationResult.errors = errorsAddFileInfo(responseSerializedErrors)
|
||||
rawValidation.requestValidationResult.errors = processErrors(
|
||||
suppression,
|
||||
requestSerializedErrors
|
||||
)
|
||||
rawValidation.responseValidationResult.errors = processErrors(
|
||||
suppression,
|
||||
responseSerializedErrors
|
||||
)
|
||||
|
||||
return rawValidation
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import { getErrorsFromModelValidation } from "./util/getErrorsFromModelValidatio
|
|||
import { SemanticValidator } from "./validators/semanticValidator"
|
||||
import { ModelValidator } from "./validators/modelValidator"
|
||||
import { MutableStringMap, StringMap } from "@ts-common/string-map"
|
||||
import { NodeError } from './util/validationError';
|
||||
import { ModelValidationError } from './util/modelValidationError';
|
||||
|
||||
type FinalValidationResult = MutableStringMap<unknown>
|
||||
|
||||
|
@ -80,6 +82,22 @@ async function validate<T>(
|
|||
}
|
||||
}
|
||||
|
||||
type ErrorType = "error" | "warning"
|
||||
|
||||
const prettyPrint = <T extends NodeError<T>>(
|
||||
errors: ReadonlyArray<T> | undefined, errorType: ErrorType
|
||||
) => {
|
||||
if (errors !== undefined) {
|
||||
for (const error of errors) {
|
||||
const yaml = jsYaml.dump(error)
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.error("\x1b[31m", errorType, ":", "\x1b[0m")
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.error(yaml)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function validateSpec(
|
||||
specPath: string,
|
||||
options: Options | undefined,
|
||||
|
@ -110,26 +128,8 @@ export async function validateSpec(
|
|||
if (o.pretty) {
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.log(`Semantically validating ${specPath}:\n`)
|
||||
const errors = validationResults.errors
|
||||
if (errors.length > 0) {
|
||||
for (const error of errors) {
|
||||
const yaml = jsYaml.dump(error)
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.error("\x1b[31m", "error:", "\x1b[0m")
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.error(yaml)
|
||||
}
|
||||
}
|
||||
const warnings = validationResults.warnings
|
||||
if (warnings && warnings.length > 0) {
|
||||
for (const warning of warnings) {
|
||||
const yaml = jsYaml.dump(warning)
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.warn("\x1b[31m", "warning:", "\x1b[0m")
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.warn(yaml)
|
||||
}
|
||||
}
|
||||
prettyPrint(validationResults.errors, "error")
|
||||
prettyPrint(validationResults.warnings, "warning")
|
||||
}
|
||||
return validator.specValidationResult
|
||||
})
|
||||
|
@ -151,7 +151,7 @@ export async function validateExamples(
|
|||
specPath: string,
|
||||
operationIds: string | undefined,
|
||||
options?: Options
|
||||
): Promise<SpecValidationResult> {
|
||||
): Promise<ReadonlyArray<ModelValidationError>> {
|
||||
return await validate(options, async o => {
|
||||
const validator = new ModelValidator(specPath, null, o)
|
||||
finalValidationResult[specPath] = validator.specValidationResult
|
||||
|
@ -160,28 +160,23 @@ export async function validateExamples(
|
|||
validator.validateOperations(operationIds)
|
||||
updateEndResultOfSingleValidation(validator)
|
||||
logDetailedInfo(validator)
|
||||
const errors = getErrorsFromModelValidation(
|
||||
validator.getSuppression(),
|
||||
validator.specValidationResult
|
||||
)
|
||||
if (o.pretty) {
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.log(`Validating "examples" and "x-ms-examples" in ${specPath}:\n`)
|
||||
const errors = getErrorsFromModelValidation(validator.specValidationResult)
|
||||
if (errors.length > 0) {
|
||||
for (const error of errors) {
|
||||
const yaml = jsYaml.dump(error)
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.error("\x1b[31m", "error:", "\x1b[0m")
|
||||
/* tslint:disable-next-line:no-console no-string-literal */
|
||||
console.error(yaml)
|
||||
}
|
||||
}
|
||||
prettyPrint(errors, "error")
|
||||
}
|
||||
return validator.specValidationResult
|
||||
return errors
|
||||
})
|
||||
}
|
||||
|
||||
export async function validateExamplesInCompositeSpec(
|
||||
compositeSpecPath: string,
|
||||
options: Options
|
||||
): Promise<ReadonlyArray<SpecValidationResult>> {
|
||||
): Promise<ReadonlyArray<ReadonlyArray<ModelValidationError>>> {
|
||||
return await validate(options, async o => {
|
||||
o.consoleLogLevel = log.consoleLogLevel
|
||||
o.logFilepath = log.filepath
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as C from "../util/constants"
|
|||
import * as util from "util"
|
||||
import { CommonError } from "../util/commonError"
|
||||
import { keys } from "@ts-common/string-map"
|
||||
import { errorsAddFileInfo } from '../util/errorFileInfo';
|
||||
import { processErrors } from "../util/processErrors"
|
||||
|
||||
export interface Result {
|
||||
isValid?: unknown
|
||||
|
@ -49,7 +49,7 @@ export class SemanticValidator extends SpecValidator<SemanticValidationResult> {
|
|||
if (validationResult) {
|
||||
if (validationResult.errors && validationResult.errors.length) {
|
||||
this.specValidationResult.validateSpec.isValid = false
|
||||
errorsAddFileInfo(validationResult.errors)
|
||||
processErrors(this.getSuppression(), validationResult.errors)
|
||||
const e = this.constructErrorObject(
|
||||
ErrorCodes.SemanticValidationError,
|
||||
`The spec ${this.specPath} has semantic validation errors.`,
|
||||
|
@ -65,7 +65,7 @@ export class SemanticValidator extends SpecValidator<SemanticValidationResult> {
|
|||
`The spec ${this.specPath} is semantically valid.`
|
||||
}
|
||||
if (validationResult.warnings && validationResult.warnings.length > 0) {
|
||||
errorsAddFileInfo(validationResult.warnings)
|
||||
processErrors(this.getSuppression(), validationResult.warnings)
|
||||
const warnings = validateResponse.sanitizeWarnings(validationResult.warnings)
|
||||
if (warnings && warnings.length) {
|
||||
this.specValidationResult.validateSpec.warnings = warnings
|
||||
|
|
|
@ -35,6 +35,7 @@ import { arrayMap } from '@ts-common/source-map'
|
|||
const ErrorCodes = C.ErrorCodes
|
||||
|
||||
export interface Options {
|
||||
consoleLogLevel?: unknown
|
||||
shouldResolveRelativePaths?: boolean | null
|
||||
shouldResolveXmsExamples?: boolean | null
|
||||
shouldResolveAllOf?: boolean
|
||||
|
|
|
@ -12,7 +12,9 @@ import * as C from "../util/constants"
|
|||
import { SwaggerObject } from "yasway"
|
||||
import { ModelValidation } from "../util/getErrorsFromModelValidation"
|
||||
import { Headers } from "../templates/httpTemplate"
|
||||
import { StringMap } from '@ts-common/string-map';
|
||||
import { StringMap } from "@ts-common/string-map"
|
||||
import { getSuppressions } from "./suppressions"
|
||||
import * as amd from "@ts-common/azure-openapi-markdown"
|
||||
|
||||
const ErrorCodes = C.ErrorCodes;
|
||||
|
||||
|
@ -78,6 +80,12 @@ export class SpecValidator<T extends CommonValidationResult> {
|
|||
|
||||
private readonly options: Options
|
||||
|
||||
private suppression?: amd.Suppression
|
||||
|
||||
public getSuppression(): amd.Suppression | undefined {
|
||||
return this.suppression
|
||||
}
|
||||
|
||||
/*
|
||||
* @constructor
|
||||
* Initializes a new instance of the SpecValidator class.
|
||||
|
@ -161,6 +169,7 @@ export class SpecValidator<T extends CommonValidationResult> {
|
|||
if (this.specInJson === undefined || this.specInJson === null) {
|
||||
const result = await utils.parseJson(this.specPath)
|
||||
this.specInJson = result
|
||||
this.suppression = getSuppressions(this.specPath)
|
||||
}
|
||||
|
||||
this.specResolver = new SpecResolver(this.specPath, this.specInJson, this.options)
|
||||
|
@ -173,9 +182,8 @@ export class SpecValidator<T extends CommonValidationResult> {
|
|||
},
|
||||
isPathCaseSensitive: this.options.isPathCaseSensitive
|
||||
}
|
||||
const api = await Sway.create(options)
|
||||
this.swaggerApi = api
|
||||
return api
|
||||
this.swaggerApi = await Sway.create(options)
|
||||
return this.swaggerApi
|
||||
} catch (err) {
|
||||
const e = this.constructErrorObject(ErrorCodes.ResolveSpecError, err.message, [err])
|
||||
this.specValidationResult.resolveSpec = e
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import * as path from "path"
|
||||
import * as fs from "fs"
|
||||
import * as md from "@ts-common/commonmark-to-markdown"
|
||||
import * as amd from "@ts-common/azure-openapi-markdown"
|
||||
|
||||
export const getSuppressions = (specPath: string): undefined | amd.Suppression => {
|
||||
// find readme.md
|
||||
const readMe = findReadMe(path.dirname(specPath))
|
||||
if (readMe === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const readMeStr = fs.readFileSync(readMe).toString()
|
||||
const cmd = md.parse(readMeStr)
|
||||
const suppressionCodeBlock = amd.getCodeBlocksAndHeadings(cmd.markDown).Suppression
|
||||
if (suppressionCodeBlock === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const suppression = amd.getYamlFromNode(suppressionCodeBlock) as amd.Suppression
|
||||
return suppression
|
||||
}
|
||||
|
||||
const findReadMe = (dir: string): string | undefined => {
|
||||
dir = path.resolve(dir)
|
||||
while (true) {
|
||||
const fileName = path.join(dir, "readme.md")
|
||||
if (fs.existsSync(fileName)) {
|
||||
return fileName
|
||||
}
|
||||
const newDir = path.dirname(dir)
|
||||
if (newDir === dir) {
|
||||
return undefined
|
||||
}
|
||||
dir = newDir
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oav",
|
||||
"version": "0.5.13",
|
||||
"version": "0.6.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -12,6 +12,27 @@
|
|||
"vscode-jsonrpc": "^3.5.0"
|
||||
}
|
||||
},
|
||||
"@ts-common/azure-openapi-markdown": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@ts-common/azure-openapi-markdown/-/azure-openapi-markdown-0.2.4.tgz",
|
||||
"integrity": "sha512-Z0hJhMtNdMprMGYGOCV2GrIu9MbnTZQldGRpqKBeX6yDOTdLKMUjQ3gruzCGacFzz95lB73AZ3q9prRLy0WA5g==",
|
||||
"requires": {
|
||||
"@ts-common/commonmark-to-markdown": "^1.1.3",
|
||||
"commonmark": "^0.28.1",
|
||||
"js-yaml": "^3.12.0",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"@ts-common/commonmark-to-markdown": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@ts-common/commonmark-to-markdown/-/commonmark-to-markdown-1.1.3.tgz",
|
||||
"integrity": "sha512-uAapecE47Q1bbMo60SFPUQ7hqMEGWK3OBdQNI2e2UkcKCqf0fXizLTNBzzEYzG9sTFJj3UzXUrLPfj/uf+xSNg==",
|
||||
"requires": {
|
||||
"@types/commonmark": "^0.27.1",
|
||||
"commonmark": "^0.28.1",
|
||||
"front-matter": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"@ts-common/iterator": {
|
||||
"version": "0.0.36",
|
||||
"resolved": "https://registry.npmjs.org/@ts-common/iterator/-/iterator-0.0.36.tgz",
|
||||
|
@ -84,23 +105,16 @@
|
|||
"resolved": "https://registry.npmjs.org/@ts-common/tuple/-/tuple-0.0.0.tgz",
|
||||
"integrity": "sha512-4ETK16scspsJamVLbsBNTU/hnZUhY0gpTiIK2F7A/3Pr6kNg5FrPNu9x+aAx2OvfyGN+U8NiGROyaZXN4v1FHg=="
|
||||
},
|
||||
"@ts-common/z-schema": {
|
||||
"version": "3.24.0",
|
||||
"resolved": "https://registry.npmjs.org/@ts-common/z-schema/-/z-schema-3.24.0.tgz",
|
||||
"integrity": "sha512-8oE5QhJmCmUztO7HS68hy6zLRkzhY8jxmHWD56TKVsZpHemF94gYgoKRKuBs72iP78Whdc0bmtjJcaWiTh899w==",
|
||||
"requires": {
|
||||
"commander": "^2.7.1",
|
||||
"core-js": "^2.5.7",
|
||||
"lodash.get": "^4.0.0",
|
||||
"lodash.isequal": "^4.0.0",
|
||||
"validator": "^10.0.0"
|
||||
}
|
||||
},
|
||||
"@types/caseless": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.1.tgz",
|
||||
"integrity": "sha512-FhlMa34NHp9K5MY1Uz8yb+ZvuX0pnvn3jScRSNAb75KHGB8d3rEU6hqMs3Z2vjuytcMfRg6c5CHMc3wtYyD2/A=="
|
||||
},
|
||||
"@types/commonmark": {
|
||||
"version": "0.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/commonmark/-/commonmark-0.27.1.tgz",
|
||||
"integrity": "sha512-3K97drCi/zJB1nExp2fx0L50FVyOUXqAlrcUwfXr2pCbR6S67iPv2bPplVaN21osWZcVBPHU1dIk5XVC4JNRqQ=="
|
||||
},
|
||||
"@types/events": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
|
||||
|
@ -247,7 +261,7 @@
|
|||
"dependencies": {
|
||||
"acorn": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
|
||||
"integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo="
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +454,7 @@
|
|||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
|
@ -498,7 +512,7 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
|
@ -684,7 +698,25 @@
|
|||
"commander": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
|
||||
"integrity": "sha1-FXFS/R56bI2YpbcVzzdt+SgARWM="
|
||||
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ=="
|
||||
},
|
||||
"commonmark": {
|
||||
"version": "0.28.1",
|
||||
"resolved": "https://registry.npmjs.org/commonmark/-/commonmark-0.28.1.tgz",
|
||||
"integrity": "sha1-Buq41SM4uDn6Gi11rwCF7tGxvq4=",
|
||||
"requires": {
|
||||
"entities": "~ 1.1.1",
|
||||
"mdurl": "~ 1.0.1",
|
||||
"minimist": "~ 1.2.0",
|
||||
"string.prototype.repeat": "^0.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||
}
|
||||
}
|
||||
},
|
||||
"component-emitter": {
|
||||
"version": "1.2.1",
|
||||
|
@ -710,7 +742,7 @@
|
|||
"content-type": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
|
||||
"integrity": "sha1-4TjMdeBAxyexlm/l5fjJruJW/js="
|
||||
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
|
||||
},
|
||||
"cookiejar": {
|
||||
"version": "2.1.2",
|
||||
|
@ -753,7 +785,7 @@
|
|||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
|
@ -843,7 +875,7 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
|
@ -874,9 +906,9 @@
|
|||
}
|
||||
},
|
||||
"drange": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/drange/-/drange-1.1.0.tgz",
|
||||
"integrity": "sha512-VmAjVQo0L3Y1563LtN/6OmiklpOzFiAqv7IkSMS+Hn/BFMPnBZMaexCP0yhnKk2pJqAv0LE4M8Qoszf587J2QQ=="
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/drange/-/drange-1.1.1.tgz",
|
||||
"integrity": "sha512-pYxfDYpued//QpnLIm4Avk7rsNtAtQkUES2cwAYSvD/wd2pKD71gN2Ebj3e7klzXwjocvE8c5vx/1fxwpqmSxA=="
|
||||
},
|
||||
"duplexer": {
|
||||
"version": "0.1.1",
|
||||
|
@ -924,6 +956,11 @@
|
|||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
|
||||
},
|
||||
"entities": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz",
|
||||
"integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA="
|
||||
},
|
||||
"env-variable": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.4.tgz",
|
||||
|
@ -973,7 +1010,7 @@
|
|||
},
|
||||
"eslint": {
|
||||
"version": "4.19.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz",
|
||||
"integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==",
|
||||
"requires": {
|
||||
"ajv": "^5.3.0",
|
||||
|
@ -1131,7 +1168,7 @@
|
|||
},
|
||||
"external-editor": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
|
||||
"integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==",
|
||||
"requires": {
|
||||
"chardet": "^0.4.0",
|
||||
|
@ -1253,6 +1290,14 @@
|
|||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||
},
|
||||
"front-matter": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/front-matter/-/front-matter-2.3.0.tgz",
|
||||
"integrity": "sha1-cgOviWzjV+4E4qpFFp6pHtf2dQQ=",
|
||||
"requires": {
|
||||
"js-yaml": "^3.10.0"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
|
@ -1385,7 +1430,7 @@
|
|||
},
|
||||
"http-errors": {
|
||||
"version": "1.6.3",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
|
||||
"resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
|
||||
"integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
|
||||
"requires": {
|
||||
"depd": "~1.1.2",
|
||||
|
@ -1407,7 +1452,7 @@
|
|||
"iconv-lite": {
|
||||
"version": "0.4.19",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
|
||||
"integrity": "sha1-90aPYBNfXl2tM5nAqBvpoWA6CCs="
|
||||
"integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
|
||||
},
|
||||
"ignore": {
|
||||
"version": "3.3.10",
|
||||
|
@ -2085,6 +2130,11 @@
|
|||
"integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==",
|
||||
"dev": true
|
||||
},
|
||||
"mdurl": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
|
||||
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4="
|
||||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
|
@ -2121,7 +2171,7 @@
|
|||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -2275,7 +2325,7 @@
|
|||
"normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
|
||||
"integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=",
|
||||
"integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
|
||||
"requires": {
|
||||
"hosted-git-info": "^2.1.4",
|
||||
"is-builtin-module": "^1.0.0",
|
||||
|
@ -5194,7 +5244,7 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
|
@ -5643,6 +5693,11 @@
|
|||
"strip-ansi": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"string.prototype.repeat": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-0.2.0.tgz",
|
||||
"integrity": "sha1-q6Nt4I3O5qWjN9SbLqHaGyj8Ds8="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
|
@ -5944,7 +5999,7 @@
|
|||
"tunnel": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.5.tgz",
|
||||
"integrity": "sha1-0VMiVHSe02Yg/NEBCGVJWh+p0K4="
|
||||
"integrity": "sha512-gj5sdqherx4VZKMcBA4vewER7zdK25Td+z1npBqpbDys4eJrLx+SlYjJvq1bDXs2irkuJM5pf8ktaEQVipkrbA=="
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
|
@ -6176,12 +6231,11 @@
|
|||
}
|
||||
},
|
||||
"yasway": {
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://registry.npmjs.org/yasway/-/yasway-1.0.12.tgz",
|
||||
"integrity": "sha512-cU+2bMS2okBh+7Y3tEvkRlyPDSCrY1OMjCZzEcZSoIXrLoX3GbDB3mKrmuuolKo3nniftHf48lebyTr7PgdDlg==",
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/yasway/-/yasway-1.0.13.tgz",
|
||||
"integrity": "sha512-bykVqk+xtW4M8kSM4PErjCouW1X7/v1H2gZ+A929SnAMhHTDQskuyhivJ/j9XbpXZTMzV9jxgBfteWKeL11jmA==",
|
||||
"requires": {
|
||||
"@ts-common/string-map": "0.0.26",
|
||||
"@ts-common/z-schema": "^3.24.0",
|
||||
"debug": "^3.1.0",
|
||||
"faker": "^4.1.0",
|
||||
"js-base64": "^2.4.8",
|
||||
|
@ -6193,7 +6247,8 @@
|
|||
"path-to-regexp": "^1.7.0",
|
||||
"rewire": "^4.0.1",
|
||||
"swagger-methods": "^1.0.0",
|
||||
"swagger-schema-official": "2.0.0-bab6bed"
|
||||
"swagger-schema-official": "2.0.0-bab6bed",
|
||||
"z-schema": "^3.24.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"isarray": {
|
||||
|
@ -6236,6 +6291,18 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"z-schema": {
|
||||
"version": "3.24.1",
|
||||
"resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.24.1.tgz",
|
||||
"integrity": "sha512-2eR8eq/v1coNqyBc5HzswEcoLbw+S33RMnR326uiuOIr97ve5vwPNMDrKS1IRCB12bZ3a8BrfGxrRwuSXUyPvw==",
|
||||
"requires": {
|
||||
"commander": "^2.7.1",
|
||||
"core-js": "^2.5.7",
|
||||
"lodash.get": "^4.0.0",
|
||||
"lodash.isequal": "^4.0.0",
|
||||
"validator": "^10.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
package.json
10
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oav",
|
||||
"version": "0.5.13",
|
||||
"version": "0.6.0",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation",
|
||||
"email": "azsdkteam@microsoft.com",
|
||||
|
@ -10,6 +10,8 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@microsoft.azure/autorest-extension-base": "1.0.13",
|
||||
"@ts-common/azure-openapi-markdown": "^0.2.4",
|
||||
"@ts-common/commonmark-to-markdown": "^1.1.3",
|
||||
"@ts-common/iterator": "0.0.36",
|
||||
"@ts-common/json": "0.0.18",
|
||||
"@ts-common/json-parser": "0.2.1",
|
||||
|
@ -17,10 +19,11 @@
|
|||
"@ts-common/source-map": "0.2.7",
|
||||
"@ts-common/string-map": "0.0.26",
|
||||
"@ts-common/tuple": "0.0.0",
|
||||
"@ts-common/z-schema": "^3.24.0",
|
||||
"z-schema": "^3.24.1",
|
||||
"@types/lodash": "^4.14.116",
|
||||
"@types/request": "^2.47.1",
|
||||
"azure-arm-resource": "^2.0.0-preview",
|
||||
"commonmark": "^0.28.1",
|
||||
"glob": "^5.0.14",
|
||||
"js-yaml": "^3.12.0",
|
||||
"json-pointer": "^0.6.0",
|
||||
|
@ -39,10 +42,11 @@
|
|||
"vscode-jsonrpc": "^3.6.2",
|
||||
"winston": "^3.0.0",
|
||||
"yargs": "^6.6.0",
|
||||
"yasway": "^1.0.12",
|
||||
"yasway": "^1.0.13",
|
||||
"yuml2svg": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/commonmark": "^0.27.1",
|
||||
"@types/glob": "^5.0.35",
|
||||
"@types/js-yaml": "^3.11.2",
|
||||
"@types/json-pointer": "^1.0.30",
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "title",
|
||||
"description": "",
|
||||
"version": "2016-11-01"
|
||||
},
|
||||
"host": "host",
|
||||
"schemes": [
|
||||
"https"
|
||||
],
|
||||
"consumes": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"produces": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"paths": {
|
||||
"/open/object": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"operationId": "Content_ProduceTypeObject",
|
||||
"description": "Operation to test produce application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Downloads stream": {
|
||||
"$ref": "./examples/download.json"
|
||||
}
|
||||
},
|
||||
"consumes": [],
|
||||
"produces": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/open/file": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"operationId": "Content_ProduceTypeFile",
|
||||
"description": "Operation to test produce application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Downloads stream": {
|
||||
"$ref": "./examples/download.json"
|
||||
}
|
||||
},
|
||||
"consumes": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/open/object/file": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"operationId": "Content_ProduceTypeObjectFormatFile",
|
||||
"description": "Operation to test produce application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Downloads stream": {
|
||||
"$ref": "./examples/download.json"
|
||||
}
|
||||
},
|
||||
"consumes": [],
|
||||
"produces": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"format": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/append/object": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"consumes": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"operationId": "Content_ConsumeTypeObject",
|
||||
"description": "Operation to test consume application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Uploads stream": {
|
||||
"$ref": "./examples/upload.json"
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "streamContents",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"required": true,
|
||||
"description": "Stream parameter description"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/append/file": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"operationId": "Content_ConsumeTypeFile",
|
||||
"description": "Operation to test consume application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Uploads stream": {
|
||||
"$ref": "./examples/upload.json"
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "streamContents",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
},
|
||||
"required": true,
|
||||
"description": "Stream parameter description"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/append/object/file": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"consumes": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"operationId": "Content_ConsumeTypeObjectFormatFile",
|
||||
"description": "Operation to test consume application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Uploads stream": {
|
||||
"$ref": "./examples/upload.json"
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "streamContents",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"format": "file"
|
||||
},
|
||||
"required": true,
|
||||
"description": "Stream parameter description"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parameters": {},
|
||||
"responses": {
|
||||
"200": {
|
||||
"body": {}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parameters": {
|
||||
"streamContents": "This is actually a byte stream. This request/response is being presented as a string for readability in the example"
|
||||
},
|
||||
"responses": {
|
||||
"200": {}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
## Suppression
|
||||
|
||||
```yaml
|
||||
directive:
|
||||
- suppress: INVALID_TYPE
|
||||
```
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
import assert from "assert"
|
||||
import * as validate from "../lib/validate"
|
||||
import { getErrorsFromModelValidation } from "../lib/util/getErrorsFromModelValidation"
|
||||
import { SerializedError } from "../lib/util/baseValidationError"
|
||||
import { ModelValidator } from '../lib/validators/modelValidator';
|
||||
|
||||
const specPath =
|
||||
`${__dirname}/modelValidation/swaggers/specification/scenarios/resource-manager/` +
|
||||
|
@ -20,7 +20,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath}" with operation "${operationIds}" ` +
|
||||
`contains model validation errors.`
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ describe("Model Validation", () => {
|
|||
pretty: true
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath}" with operation "${operationIds}" ` +
|
||||
`contains model validation errors.`
|
||||
)
|
||||
|
@ -53,19 +53,12 @@ describe("Model Validation", () => {
|
|||
)
|
||||
|
||||
assert(
|
||||
result.validityStatus === false,
|
||||
`swagger "${specPath}" with operation "${operationIds}" ` +
|
||||
`contains model validation errors.`
|
||||
)
|
||||
|
||||
const serializedErrors = getErrorsFromModelValidation(result)
|
||||
assert(
|
||||
serializedErrors.length === 1,
|
||||
result.length === 1,
|
||||
`swagger "${specPath} with operation "${operationIds}" should report only 1 error.`
|
||||
)
|
||||
|
||||
assert(
|
||||
(serializedErrors[0].errorDetails as SerializedError).similarPaths
|
||||
(result[0].errorDetails as SerializedError).similarPaths
|
||||
.length === 1,
|
||||
`swagger "${specPath} with operation "${operationIds}" error should have a similar path.`
|
||||
)
|
||||
|
@ -78,7 +71,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -90,7 +83,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -103,7 +96,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === false,
|
||||
result.length !== 0,
|
||||
`swagger "${specPath}" with operation "${operationIds}" contains passed incorrectly.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -122,7 +115,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -135,7 +128,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -148,7 +141,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -157,9 +150,16 @@ describe("Model Validation", () => {
|
|||
it("should fail for CircularAnimal_IncorrectSibling_List", async () => {
|
||||
const specPath2 = `${__dirname}/modelValidation/swaggers/specification/polymorphic/polymorphicSwagger.json`
|
||||
const operationIds = "CircularAnimal_IncorrectSibling_List"
|
||||
const result = await validate.validateExamples(specPath2, operationIds, {
|
||||
consoleLogLevel: "off"
|
||||
})
|
||||
const validator = new ModelValidator(
|
||||
specPath2,
|
||||
null,
|
||||
{
|
||||
consoleLogLevel: "off"
|
||||
}
|
||||
)
|
||||
await validator.initialize()
|
||||
validator.validateOperations(operationIds)
|
||||
const result = validator.specValidationResult
|
||||
assert(
|
||||
result.validityStatus === false,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
|
@ -211,7 +211,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -225,7 +225,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -240,7 +240,7 @@ describe("Model Validation", () => {
|
|||
})
|
||||
console.dir(result, { depth: null })
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -253,7 +253,7 @@ describe("Model Validation", () => {
|
|||
})
|
||||
console.dir(result, { depth: null })
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -268,7 +268,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -281,7 +281,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -294,7 +294,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -307,7 +307,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -320,7 +320,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -333,7 +333,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -346,7 +346,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -359,7 +359,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -372,7 +372,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -385,7 +385,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -398,7 +398,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -411,7 +411,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -424,7 +424,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -437,7 +437,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -450,7 +450,7 @@ describe("Model Validation", () => {
|
|||
consoleLogLevel: "off"
|
||||
})
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" with operation "${operationIds}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -465,7 +465,7 @@ describe("Model Validation", () => {
|
|||
})
|
||||
console.dir(result, { depth: null })
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -480,7 +480,7 @@ describe("Model Validation", () => {
|
|||
})
|
||||
console.dir(result, { depth: null })
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
@ -495,7 +495,7 @@ describe("Model Validation", () => {
|
|||
})
|
||||
console.dir(result, { depth: null })
|
||||
assert(
|
||||
result.validityStatus === true,
|
||||
result.length === 0,
|
||||
`swagger "${specPath2}" contains model validation errors.`
|
||||
)
|
||||
console.log(result)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import * as sway from "yasway"
|
||||
import assert from "assert"
|
||||
import { SpecValidator } from "../lib/validators/specValidator"
|
||||
import { jsonSymbol } from "@ts-common/z-schema"
|
||||
import { jsonSymbol } from "z-schema"
|
||||
|
||||
const options: sway.Options = {
|
||||
definition: {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { validateExamples } from "../lib/validate"
|
||||
import * as assert from "assert"
|
||||
|
||||
describe("suppression", () => {
|
||||
it("no readme", async () => {
|
||||
const result = await validateExamples(
|
||||
"./test/modelValidation/swaggers/specification/suppressions/datalake.json",
|
||||
undefined,
|
||||
{
|
||||
consoleLogLevel: "off"
|
||||
}
|
||||
)
|
||||
assert.strictEqual(result.length, 0)
|
||||
})
|
||||
})
|
Загрузка…
Ссылка в новой задаче