diff --git a/demo/main.js b/demo/main.js index 836eaa45..2762004b 100644 --- a/demo/main.js +++ b/demo/main.js @@ -5,9 +5,31 @@ var schemaUrlInput = document.getElementById('schema-url-input'); schemaUrlForm.addEventListener('submit', function(event) { event.preventDefault(); - Redoc.init(schemaUrlInput.value); + event.stopPropagation(); + location.search = updateQueryStringParameter(location.search, 'url', schemaUrlInput.value) return false; }) + var url = window.location.search.match(/url=([^&]+)/); + if (url && url.length > 1) { + url = decodeURIComponent(url[1]); + document.getElementsByTagName('redoc')[0].setAttribute('spec-url', url); + schemaUrlInput.value = url; + } + + function updateQueryStringParameter(uri, key, value) { + var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)", "i"); + if (uri.match(re)) { + return uri.replace(re, '$1' + key + "=" + value + '$2'); + } else { + var hash = ''; + if( uri.indexOf('#') !== -1 ){ + hash = uri.replace(/.*#/, '#'); + uri = uri.replace(/#.*/, ''); + } + var separator = uri.indexOf('?') !== -1 ? "&" : "?"; + return uri + separator + key + "=" + value + hash; + } + } //window.redocDebugMode = true; })(); diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index 51942c3f..c03e356b 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -133,7 +133,7 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; height: ($param-name-height/2) + $cell-padding + 1; } -.param:last-of-type > .param-name { +.param:last-of-type > .param-name, .param.last > .param-name { position: relative; &:after { @@ -156,6 +156,10 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; display: none !important; } +.param-schema.last > td { + border-left: 0; +} + .param-enum { color: $text-color; font-size: 13px; diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index a8c7b589..bbf20974 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -55,7 +55,8 @@ export default class JsonSchemaLazy { let $element = compRef.location.nativeElement; // skip caching view with tabs inside (discriminator) as it needs attached controller - if ($element.querySelector('tabs')) { + // FIXME: get rid of dependency on selector + if ($element.querySelector('.discriminator-wrap')) { this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { compRef.instance.pointer = this.pointer; compRef.hostView.changeDetectorRef.markForCheck(); diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index 6d2d4e8a..bd3155ee 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -1,10 +1,17 @@ - - {{_displayType}} + + {{schema._displayType}} {{schema._displayFormat}} + {{schema._range}} + +
+ {{enumItem.val | json}} +
- -