From edf0e7423ce0115ba964f2de5af86abe2b78ea0a Mon Sep 17 00:00:00 2001 From: Evgenii Fedoseev Date: Wed, 21 Dec 2022 13:08:47 +0300 Subject: [PATCH] fix: parse JSON schema --- package-lock.json | 8 ++++++-- package.json | 2 ++ .../includers/batteries/openapi/generators/endpoint.ts | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0e1b3445..42a6fa06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2185,6 +2185,11 @@ "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", "dev": true }, + "@types/json-stringify-safe": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/json-stringify-safe/-/json-stringify-safe-5.0.0.tgz", + "integrity": "sha512-UUA1sH0RSRROdInuDOA1yoRzbi5xVFD1RHCoOvNRPTNwR8zBkJ/84PZ6NhKVDtKp0FTeIccJCdQz1X2aJPr4uw==" + }, "@types/linkify-it": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", @@ -6717,8 +6722,7 @@ "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" }, "json5": { "version": "2.2.0", diff --git a/package.json b/package.json index 2b325bad..c976992a 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@doc-tools/yfm2xliff": "0.0.3", "@octokit/core": "3.5.1", "@types/glob": "^8.0.0", + "@types/json-stringify-safe": "^5.0.0", "@yandex-cloud/nodejs-sdk": "^2.2.2", "ajv": "^8.11.0", "async": "^3.2.4", @@ -44,6 +45,7 @@ "glob": "^8.0.3", "highlight.js": "10.7.3", "js-yaml": "4.1.0", + "json-stringify-safe": "^5.0.1", "mime-types": "2.1.34", "node-html-parser": "^5.3.3", "react": "16.14.0", diff --git a/src/services/includers/batteries/openapi/generators/endpoint.ts b/src/services/includers/batteries/openapi/generators/endpoint.ts index 7a9fc4cd..4817c0fe 100644 --- a/src/services/includers/batteries/openapi/generators/endpoint.ts +++ b/src/services/includers/batteries/openapi/generators/endpoint.ts @@ -1,3 +1,5 @@ +import stringify from 'json-stringify-safe'; + import {block, title, body, table, code, cut} from './common'; import { DESCRIPTION_SECTION_NAME, @@ -67,7 +69,7 @@ function response(resp: Response) { /* eslint-disable-next-line no-shadow */ function schema({type, schema}: Schema) { - return cut(code(JSON.stringify(schema, null, 4)), type); + return cut(code(stringify(schema, null, 4)), type); } export {endpoint};