api-typescript-generator
Advanced tools
Comparing version 2.5.3 to 2.5.4
@@ -13,8 +13,15 @@ "use strict"; | ||
} | ||
function stringifyExample(example) { | ||
const result = JSON.stringify(example, null, 2); | ||
if (Array.isArray(example)) { | ||
return '```\n' + result + '\n```'; | ||
} | ||
return result; | ||
} | ||
function exampleToString(example) { | ||
if (typeof example !== 'string') { | ||
return JSON.stringify(example, null, 4); | ||
return stringifyExample(example); | ||
} | ||
try { | ||
return JSON.stringify(JSON.parse(example), null, 2); | ||
return stringifyExample(JSON.parse(example)); | ||
} | ||
@@ -67,3 +74,8 @@ catch (e) { | ||
if (value.match(/^[\n]/)) { | ||
result += `:\n\`\`\`${value}\`\`\``; | ||
if (value.match(/^\n```/)) { | ||
result += `:\n${value}`; | ||
} | ||
else { | ||
result += `:\n\`\`\`${value}\`\`\``; | ||
} | ||
} | ||
@@ -70,0 +82,0 @@ else { |
{ | ||
"name": "api-typescript-generator", | ||
"version": "2.5.3", | ||
"version": "2.5.4", | ||
"description": "Generates OpenAPI TypeScript client. Extremely fast and flexible.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
474342
6841