bootprint-openapi
Advanced tools
Comparing version 0.17.0 to 0.17.1
# Release notes | ||
<a name="current-release"></a> | ||
# Version 0.17.1 (Sat, 17 Dec 2016 08:24:37 GMT) | ||
* [fa9f407](https://github.com/bootprint/bootprint-openapi/commit/fa9f407) Render response examples as highlighted text, if it is not an Object. (#82) - Nils Knappmeier | ||
# Version 0.17.0 (Fri, 01 Jul 2016 07:53:44 GMT) | ||
@@ -5,0 +9,0 @@ |
@@ -0,1 +1,8 @@ | ||
var _ = require('lodash') | ||
var highlight = require('highlight.js') | ||
highlight.configure({ | ||
'useBR': true | ||
}) | ||
module.exports = { | ||
@@ -74,3 +81,33 @@ 'swagger--collection-format': function (value, paramName) { | ||
}[code] | ||
}, | ||
/** | ||
* Render the value of an [Example object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#exampleObject) | ||
* | ||
* * If the mime-type is `application/json`, and the example is an object, | ||
* it will be stringified | ||
* | ||
* * If the mime-type is `application/xml`, and the example is an object, | ||
* the json should be converted to XML (which is not the case at the moment | ||
* TODO, help wanted) | ||
* | ||
* @param {any} example the value of an [Example Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#exampleObject) | ||
* @param {string} mimeType the mime-type of this example | ||
*/ | ||
'swagger--example': function (example, mimeType, options, customize) { | ||
if (_.isObject(example)) { | ||
switch (mimeType) { | ||
case 'application/json': | ||
example = require('json-stable-stringify')(example, {space: 4}) | ||
break | ||
case 'application/xml': | ||
// TODO: This should actually convert the example to XML but I don't know how yet. "help wanted" | ||
example = require('json-stable-stringify')(example, {space: 4}) | ||
break | ||
} | ||
} | ||
var highlighted = highlight.highlightAuto(String(example)).value | ||
var fixMarkup = highlight.fixMarkup(highlighted) | ||
return new customize.engine.SafeString('<pre>' + fixMarkup + '</pre>') | ||
} | ||
} |
{ | ||
"name": "bootprint-openapi", | ||
"version": "0.17.0", | ||
"version": "0.17.1", | ||
"description": "Converts a openapi-definition into a static html page", | ||
@@ -22,2 +22,4 @@ "main": "index.js", | ||
"bootprint-json-schema": "<1.0.0", | ||
"highlight.js": "^8.9.1", | ||
"json-stable-stringify": "^1.0.1", | ||
"lodash": "^3.9.3" | ||
@@ -24,0 +26,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196
44244
4
29
+ Addedhighlight.js@^8.9.1
+ Addedjson-stable-stringify@^1.0.1