From ad68695009201a2a0bf2abf3eef6cc8d1c1d11c5 Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Tue, 7 Oct 2014 11:07:41 +0200 Subject: [PATCH] Add syntax highlighting styles & highlight threshold. Previously, highlighting classes were being added to the DOM but had no CSS so the user just saw black - a lot of CPU usage for nothing. These styles now attractively and minimally style resposes so long as they are below a certain threshold, as well as model schemas. The highlightSizeThreshold fixes the long hang users would see when large responses were returned. --- public/css/loopbackStyles.css | 13 +++++++++++++ public/lib/loadSwaggerUI.js | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/public/css/loopbackStyles.css b/public/css/loopbackStyles.css index 8065c59..04d6894 100644 --- a/public/css/loopbackStyles.css +++ b/public/css/loopbackStyles.css @@ -21,6 +21,19 @@ bottom: -30px; } +/* JSON syntax highlighting */ +.json, .json .attribute { + color: black; +} + +.json .value .string { + color: #800; +} + +.json .value .number, .json .value .literal { + color: #080; +} + /* FIXME: Separate the overrides from the rest of the styles, rather than override screen.css entirely. */ diff --git a/public/lib/loadSwaggerUI.js b/public/lib/loadSwaggerUI.js index 241d335..32c02fd 100644 --- a/public/lib/loadSwaggerUI.js +++ b/public/lib/loadSwaggerUI.js @@ -26,7 +26,8 @@ $(function() { log('Unable to Load SwaggerUI'); log(data); }, - docExpansion: 'none' + docExpansion: 'none', + highlightSizeThreshold: 16384 }); $('#explore').click(setAccessToken);