This commit is contained in:
Sergey Shandar 2019-01-15 16:11:52 -08:00 коммит произвёл GitHub
Родитель c2c858da20
Коммит 3b13b883d5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 35 добавлений и 36 удалений

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

@ -1,5 +1,9 @@
# Changelog
### 01/15/2019 0.13.0
- JSON types are updated.
### 01/14/2019 0.12.0
- Simplify model and semantic property names. `errorCode` becomes `code` and `errorDetails` becomes `details`.

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

@ -11,8 +11,8 @@ import { getDescendantFilePosition } from "@ts-common/source-map"
import { setMutableProperty } from "@ts-common/property-set"
import { merge } from "@ts-common/string-map"
export const processErrors = <T extends NodeError<T>>(errors: T[] | undefined): T[] | undefined =>
createErrorProcessor<T>()(errors)
export const processErrors = <T extends NodeError<T>>(errors: T[] | undefined) =>
errors === undefined ? undefined : Array.from(filterMap(errors, one))
const addFileInfo = <T extends NodeError<T>>(error: T): T => {
const title = error.title
@ -55,26 +55,18 @@ const addFileInfo = <T extends NodeError<T>>(error: T): T => {
return error
}
const createErrorProcessor = <T extends NodeError<T>>() => {
const isSuppressed = <T extends NodeError<T>>(error: T): boolean =>
error.directives !== undefined &&
error.code !== undefined &&
error.directives[error.code] !== undefined
const isSuppressed = (error: T): boolean =>
error.directives !== undefined &&
error.code !== undefined &&
error.directives[error.code] !== undefined
const one = (error: T): T | undefined => {
error = addFileInfo(error)
if (isSuppressed(error)) {
return undefined
}
setMutableProperty(error, "errors", multiple(error.errors))
setMutableProperty(error, "inner", multiple(error.inner))
setMutableProperty(error, "innerErrors", multiple(error.innerErrors))
return error
const one = <T extends NodeError<T>>(error: T): T | undefined => {
error = addFileInfo(error)
if (isSuppressed(error)) {
return undefined
}
const multiple = (errors: T[] | undefined) =>
errors === undefined ? undefined : Array.from(filterMap(errors, one))
return multiple
setMutableProperty(error, "errors", processErrors(error.errors))
setMutableProperty(error, "inner", processErrors(error.inner))
setMutableProperty(error, "innerErrors", processErrors(error.innerErrors))
return error
}

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

@ -17,6 +17,9 @@ import {
copyInfo
} from "@ts-common/source-map"
import { getSchemaObjectInfo, setSchemaInfo } from "../validators/specTransformer"
import * as json from "@ts-common/json"
import * as it from "@ts-common/iterator"
import * as sm from "@ts-common/string-map"
/*
* Executes an array of promises sequentially. Inspiration of this method is here:
@ -456,10 +459,10 @@ export function isPureObject(model: SchemaObject): boolean {
typeof model.type.valueOf() === "string" &&
model.type === "object" &&
model.properties &&
model.properties.length === 0
it.isEmpty(sm.entries(model.properties))
) {
return true
} else if (!model.type && model.properties && model.properties.length === 0) {
} else if (!model.type && model.properties && it.isEmpty(sm.entries(model.properties))) {
return true
} else if (
model.type &&
@ -474,7 +477,7 @@ export function isPureObject(model: SchemaObject): boolean {
}
}
interface Entity {
type Entity = {
in?: string
type?: DataType
additionalProperties?: SchemaObject | boolean
@ -483,7 +486,7 @@ interface Entity {
oneOf?: ReadonlyArray<SchemaObject>
$ref?: string
anyOf?: ReadonlyArray<SchemaObject>
}
} & json.JsonObject
/**
* Relaxes/Transforms the given entities type from a specific JSON schema primitive type

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

@ -7,7 +7,8 @@ import { FilePosition } from "@ts-common/source-map"
import { flatMap, fold } from "@ts-common/iterator"
import { processErrors } from "./processErrors"
import { jsonSymbol, schemaSymbol } from "z-schema"
import { StringMap } from '@ts-common/string-map';
import { StringMap } from "@ts-common/string-map"
import * as json from "@ts-common/json"
/**
* @class
@ -111,7 +112,7 @@ export interface NodeError<T extends NodeError<T>> {
directives?: StringMap<unknown>
readonly [jsonSymbol]?: object
readonly [jsonSymbol]?: json.JsonRef
readonly [schemaSymbol]?: object
}

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

@ -23,8 +23,8 @@ import {
import { PartialFactory } from "@ts-common/property-set"
import { MutableStringMap } from "@ts-common/string-map"
import { pathToPtr } from "json-refs"
import { setSchemaTitle, getSchemaObjectInfo, setSchemaInfo } from './specTransformer';
import { generatedPrefix } from './cloudError';
import { setSchemaTitle, getSchemaObjectInfo, setSchemaInfo } from "./specTransformer"
import { generatedPrefix } from "./cloudError"
const skipIfUndefined = <T>(f: (v: T) => T): ((v: T | undefined) => T | undefined) =>
(v) => v !== undefined ? f(v) : undefined
@ -65,11 +65,10 @@ export function resolveNestedDefinitions(spec: SwaggerObject): SwaggerObject {
setSchemaInfo(refResult, getSchemaObjectInfo(schemaObject))
return refResult
}
// a function to resolve SchemaObject array
const resolveOptionalSchemaObjectArray = (
schemaObjectArray: ReadonlyArray<SchemaObject> | undefined
) =>
): ReadonlyArray<SchemaObject> | undefined =>
schemaObjectArray !== undefined ?
arrayMap(schemaObjectArray, resolveNestedSchemaObject) :
undefined

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

@ -1,6 +1,6 @@
{
"name": "oav",
"version": "0.12.0",
"version": "0.13.0",
"author": {
"name": "Microsoft Corporation",
"email": "azsdkteam@microsoft.com",
@ -14,9 +14,9 @@
"@ts-common/commonmark-to-markdown": "^1.1.3",
"@ts-common/iterator": "^0.1.1",
"@ts-common/json": "^0.2.0",
"@ts-common/json-parser": "^0.4.0",
"@ts-common/json-parser": "^0.5.0",
"@ts-common/property-set": "^0.0.9",
"@ts-common/source-map": "^0.3.3",
"@ts-common/source-map": "^0.4.0",
"@ts-common/string-map": "^0.2.2",
"@ts-common/tuple": "^0.0.5",
"@ts-common/virtual-fs": "^0.1.1",
@ -41,7 +41,7 @@
"vscode-jsonrpc": "^3.6.2",
"winston": "^3.1.0",
"yargs": "^6.6.0",
"yasway": "1.4.0",
"yasway": "1.5.10",
"yuml2svg": "^3.1.0",
"z-schema": "^3.24.2"
},