Fix for special symbols inside JSON-Pointer/Reference (#308)
* test for nested properties with `@` character. * update json-refs. * fix JSON-Pointer
This commit is contained in:
Родитель
5417eec6d6
Коммит
5f43b2db45
|
@ -85,7 +85,7 @@
|
|||
"stopOnEntry": false,
|
||||
"args": [
|
||||
"--no-timeouts",
|
||||
"test/resolveNestedTests.ts",
|
||||
"test/semanticValidatorTests.ts",
|
||||
"-r",
|
||||
"ts-node/register",
|
||||
"--no-timeouts"
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
### 09/10/2018 0.5.8
|
||||
|
||||
- Fix JSON-Pointer encoding.
|
||||
|
||||
### 08/28/2018 0.5.7
|
||||
|
||||
- Errors have optional `jsonUrl` and `jsonPosition` fields.
|
||||
|
|
|
@ -28,6 +28,7 @@ import {
|
|||
generatedPrefix,
|
||||
getDefaultResponses
|
||||
} from './cloudError';
|
||||
import { pathToPtr } from 'json-refs';
|
||||
|
||||
const skipIfUndefined = <T>(f: (v: T) => T): ((v: T | undefined) => T | undefined) =>
|
||||
(v) => v !== undefined ? f(v) : undefined
|
||||
|
@ -64,7 +65,7 @@ export function resolveNestedDefinitions(spec: SwaggerObject, options: Options):
|
|||
if (result !== undefined) {
|
||||
generatedDefinitions[definitionName] = result
|
||||
}
|
||||
return { $ref: `#/definitions/${encodeURIComponent(definitionName)}` }
|
||||
return { $ref: pathToPtr(["definitions", definitionName]) }
|
||||
}
|
||||
|
||||
// a function to resolve SchemaObject array
|
||||
|
|
|
@ -264,7 +264,7 @@ export class SpecResolver {
|
|||
* @return {Promise<void>}
|
||||
*/
|
||||
private async resolveRelativePaths(
|
||||
doc?: unknown,
|
||||
doc?: object,
|
||||
docPath?: string,
|
||||
filterType?: string
|
||||
): Promise<void> {
|
||||
|
|
|
@ -192,7 +192,7 @@ export class WireFormatGenerator {
|
|||
filter: ["relative", "remote"]
|
||||
}
|
||||
|
||||
const allRefsRemoteRelative = JsonRefs.findRefs(this.specInJson, options)
|
||||
const allRefsRemoteRelative = JsonRefs.findRefs(this.specInJson as object, options)
|
||||
const e = entries(allRefsRemoteRelative as StringMap<any>)
|
||||
const promiseFactories = toArray(map(
|
||||
e,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oav",
|
||||
"version": "0.5.7",
|
||||
"version": "0.5.8",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1618,16 +1618,16 @@
|
|||
}
|
||||
},
|
||||
"json-refs": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/json-refs/-/json-refs-3.0.6.tgz",
|
||||
"integrity": "sha512-umW/uhtvq2YO+MRtHXUiSIlaoslME3xjnpQJ5rkCQoF5RpDfuBqkbO22W3H4Q16VDOTECKHceqYQzef7sT/Hig==",
|
||||
"version": "3.0.10",
|
||||
"resolved": "https://registry.npmjs.org/json-refs/-/json-refs-3.0.10.tgz",
|
||||
"integrity": "sha512-hTBuXx9RKpyhNhCEh7AUm0Emngxf9f1caw4BzH9CQSPlTqxSJG/X5W0di8AHSeePu+ZqSYjlXLU6u2+Q/6wFmw==",
|
||||
"requires": {
|
||||
"commander": "~2.11.0",
|
||||
"graphlib": "^2.1.1",
|
||||
"js-yaml": "^3.10.0",
|
||||
"lodash": "^4.17.4",
|
||||
"native-promise-only": "^0.8.1",
|
||||
"path-loader": "^1.0.4",
|
||||
"path-loader": "^1.0.5",
|
||||
"slash": "^1.0.0",
|
||||
"uri-js": "^3.0.2"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oav",
|
||||
"version": "0.5.7",
|
||||
"version": "0.5.8",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation",
|
||||
"email": "azsdkteam@microsoft.com",
|
||||
|
@ -23,7 +23,7 @@
|
|||
"glob": "^5.0.14",
|
||||
"js-yaml": "^3.12.0",
|
||||
"json-pointer": "^0.6.0",
|
||||
"json-refs": "3.0.6",
|
||||
"json-refs": "3.0.10",
|
||||
"jsonpath": "^1.0.0",
|
||||
"linq": "^3.1.0",
|
||||
"lodash": "^4.17.10",
|
||||
|
|
|
@ -11,10 +11,10 @@ const options: sway.Options = {
|
|||
definitions: {
|
||||
A: {
|
||||
properties: {
|
||||
a: {
|
||||
"a": {
|
||||
type: "string"
|
||||
},
|
||||
b: {
|
||||
"b": {
|
||||
properties: {
|
||||
c: {
|
||||
type: "string"
|
||||
|
@ -22,6 +22,13 @@ const options: sway.Options = {
|
|||
},
|
||||
// additionalProperties: false,
|
||||
required: ["c"]
|
||||
},
|
||||
"@": {
|
||||
properties: {
|
||||
c: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
required: ["a", "b"],
|
||||
|
@ -63,11 +70,14 @@ describe("resolve nested properties", () => {
|
|||
url: "example.com",
|
||||
method: "x",
|
||||
body: {
|
||||
a: "somevalue",
|
||||
b: {
|
||||
"a": "somevalue",
|
||||
"b": {
|
||||
c: "somevalue",
|
||||
// d: "anothervalue"
|
||||
},
|
||||
"@": {
|
||||
c: "somevalue",
|
||||
}
|
||||
// d: 54
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1303,6 +1303,13 @@
|
|||
"properties": {
|
||||
"error": {
|
||||
"$ref": "#/definitions/Error"
|
||||
},
|
||||
"@nested": {
|
||||
"properties": {
|
||||
"@a": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
declare module "json-refs" {
|
||||
function findRefs(_0: unknown, _1?: unknown): unknown
|
||||
}
|
Загрузка…
Ссылка в новой задаче