diff --git a/README.md b/README.md index ffedfd87..e05a3c1e 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica * `hide-hostname` - if set, the protocol and hostname is not shown in the operation definition. * `expand-responses` - specify which responses to expand by default by response codes. Values should be passed as comma-separated list without spaces e.g. `expand-responses="200,201"`. Special value `"all"` expands all responses by default. Be careful: this option can slow-down documentation rendering time. * `required-props-first` - show required properties first ordered in the same order as in `required` array. +* `no-auto-auth` - do not inject Authentication section automatically ## Advanced usage Instead of adding `spec-url` attribute to the `` element you can initialize ReDoc via globally exposed `Redoc` object: diff --git a/build/webpack.common.js b/build/webpack.common.js index 30e9a57d..da047652 100644 --- a/build/webpack.common.js +++ b/build/webpack.common.js @@ -23,7 +23,7 @@ module.exports = function (options) { extensions: ['.ts', '.js', '.json', '.css'], alias: { http: 'stream-http', - https: 'stream-http' + https: 'https-browserify' } }, diff --git a/lib/components/ApiInfo/api-info.html b/lib/components/ApiInfo/api-info.html index e11178c8..725de4e9 100644 --- a/lib/components/ApiInfo/api-info.html +++ b/lib/components/ApiInfo/api-info.html @@ -6,7 +6,7 @@

- Contact: + Contact: {{info.contact.name || info.contact.url}} diff --git a/lib/components/EndpointLink/endpoint-link.scss b/lib/components/EndpointLink/endpoint-link.scss index 3bcbc510..9a70ba0a 100644 --- a/lib/components/EndpointLink/endpoint-link.scss +++ b/lib/components/EndpointLink/endpoint-link.scss @@ -110,3 +110,39 @@ transform: translateY(0%) scaleY(1); } } + +.http-verb { + color: white; + + &.get { + background-color: $get-color; + } + + &.post { + background-color: $post-color; + } + + &.put { + background-color: $put-color; + } + + &.options { + background-color: $options-color; + } + + &.patch { + background-color: $patch-color; + } + + &.delete { + background-color: $delete-color; + } + + &.basic { + background-color: $basic-color; + } + + &.link { + background-color: $link-color; + } +} diff --git a/lib/components/JsonSchema/json-schema-lazy.ts b/lib/components/JsonSchema/json-schema-lazy.ts index 24e2f1cb..c3a81bb1 100644 --- a/lib/components/JsonSchema/json-schema-lazy.ts +++ b/lib/components/JsonSchema/json-schema-lazy.ts @@ -36,7 +36,7 @@ export class JsonSchemaLazy implements OnDestroy, OnInit, AfterViewInit { return schema && schema.$ref || this.pointer; } - _loadAfterSelf() { + private _loadAfterSelf() { var componentFactory = this.resolver.resolveComponentFactory(JsonSchema); let contextInjector = this.location.parentInjector; let compRef = this.location.createComponent(componentFactory, null, contextInjector, null); diff --git a/lib/components/Operation/operation.ts b/lib/components/Operation/operation.ts index 7931069a..9b635cd4 100644 --- a/lib/components/Operation/operation.ts +++ b/lib/components/Operation/operation.ts @@ -4,9 +4,9 @@ import JsonPointer from '../../utils/JsonPointer'; import { BaseComponent, SpecManager } from '../base'; import { SchemaHelper } from '../../services/schema-helper.service'; import { OptionsService, MenuService } from '../../services/'; +import { SwaggerBodyParameter } from '../../utils/swagger-typings'; - -interface OperationInfo { +export interface OperationInfo { verb: string; path: string; info: { @@ -72,7 +72,7 @@ export class Operation extends BaseComponent implements OnInit { return tags.filter(tag => tagsMap[tag] && tagsMap[tag]['x-traitTag']); } - findBodyParam() { + findBodyParam():SwaggerBodyParameter { let params = this.specMgr.getOperationParams(this.pointer); let bodyParam = params.find(param => param.in === 'body'); return bodyParam; diff --git a/lib/components/OperationsList/operations-list.html b/lib/components/OperationsList/operations-list.html index 0907c592..aa57ed89 100644 --- a/lib/components/OperationsList/operations-list.html +++ b/lib/components/OperationsList/operations-list.html @@ -1,7 +1,7 @@

-

{{tag.name}}

+

{{tag.name}}

diff --git a/lib/components/OperationsList/operations-list.scss b/lib/components/OperationsList/operations-list.scss index 04f32b6f..a66e1310 100644 --- a/lib/components/OperationsList/operations-list.scss +++ b/lib/components/OperationsList/operations-list.scss @@ -12,7 +12,6 @@ .tag-info { padding: $section-spacing; box-sizing: border-box; - background-color: white; width: 60%; @media (max-width: $right-panel-squash-breakpoint) { diff --git a/lib/components/OperationsList/operations-list.ts b/lib/components/OperationsList/operations-list.ts index a0284321..620f4c3f 100644 --- a/lib/components/OperationsList/operations-list.ts +++ b/lib/components/OperationsList/operations-list.ts @@ -30,7 +30,10 @@ export class OperationsList extends BaseComponent implements OnInit { if (!menuItem.metadata) return; if (menuItem.metadata.type === 'tag') { - this.tags.push(menuItem); + this.tags.push({ + ...menuItem, + anchor: this.buildAnchor(menuItem.id) + }); } if (menuItem.metadata.type === 'operation' && !menuItem.parent) { emptyTag.items.push(menuItem); @@ -39,6 +42,11 @@ export class OperationsList extends BaseComponent implements OnInit { if (emptyTag.items.length) this.tags.push(emptyTag); } + buildAnchor(tagId):string { + return this.menu.hashFor(tagId, + { type: 'tag'}); + } + trackByTagName(_, el) { return el.name; } diff --git a/lib/components/Redoc/redoc.scss b/lib/components/Redoc/redoc.scss index 415a7940..d9503f00 100644 --- a/lib/components/Redoc/redoc.scss +++ b/lib/components/Redoc/redoc.scss @@ -113,6 +113,73 @@ side-menu { font-size: 18px; } +/* global menu items styles (search results + menu) */ +:host /deep/ { + .menu-item-header > span { + display: inline-block; + vertical-align: middle; + } + + .menu-item-header > .operation-type + .menu-item-title { + width: calc(100% - 32px); // 32 = 26px image width + 6px margin left + } + + .menu-item-header > .operation-type { + width: 26px; + display: inline-block; + height: 13px; + background-color: #333; + border-radius: 3px; + vertical-align: top; + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAACgCAYAAADuDlcXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJod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Ps+2HhIM4YGq0a4oDgiGjYTKw20/OwUzAEuXz73YSqtdsV+F1a3eZpweFEGGG7Y3ULbJRk4nYPlEHbUi86wpNtbz4oB37PICOrLEdC9DKzFv7EkQ8tYY8Nr8tuyJrRsdpMrIJ0n4GPBmGEEUbYzRMKnFwug1B7rppmbCiyBjBrQ1vC8KW/CxrF7osNrRbxMjofWsIIuwU2vapnZfTRq4/wFXl3hG9bMzP6ZWV47LoB+Gym1/EyUleKI2GEPW8pQpu80bHLvsifSWFVAVEzo2VDTxxb9T16eO7sF0vmxPNPxPFHgAEA/rGUMXq/uWcAAAAASUVORK5CYII='); + background-repeat: no-repeat; + background-position: 6px 4px; + text-indent: -9000px; + margin-right: 6px; + margin-top: 2px; + + &.get { + background-position: 8px -12px; + background-color: $get-color; + } + + &.post { + background-position: 6px 4px; + background-color: $post-color; + } + + &.put { + background-position: 8px -28px; + background-color: $put-color; + } + + &.options { + background-position: 4px -148px; + background-color: $options-color; + } + + &.patch { + background-position: 4px -114px; + background-color: $patch-color; + } + + &.delete { + background-position: 4px -44px; + background-color: $delete-color; + } + + &.basic { + background-position: 5px -79px; + background-color: $basic-color; + } + + &.link { + background-position: 4px -131px; + background-color: $link-color; + } + } +} + /* global redoc styles */ @for $index from 1 through 5 { @@ -240,6 +307,9 @@ footer { padding-left: 2em; margin: 0; margin-bottom: 1em; + font-family: $base-font, $base-font-family; + font-weight: $base-font-weight; + line-height: $base-line-height; } table { diff --git a/lib/components/Search/redoc-search.html b/lib/components/Search/redoc-search.html index 2c4e3a21..5c7becf6 100644 --- a/lib/components/Search/redoc-search.html +++ b/lib/components/Search/redoc-search.html @@ -5,9 +5,10 @@
diff --git a/lib/components/Search/redoc-search.scss b/lib/components/Search/redoc-search.scss index 19bee15a..c58fc3b5 100644 --- a/lib/components/Search/redoc-search.scss +++ b/lib/components/Search/redoc-search.scss @@ -44,6 +44,7 @@ input { overflow-y: auto; border-bottom: 1px solid darken($side-bar-bg-color, 10%); border-top: 1px solid darken($side-bar-bg-color, 10%); + line-height: 1.2; min-height: 150px; max-height: 250px; diff --git a/lib/components/Search/redoc-search.ts b/lib/components/Search/redoc-search.ts index 35a66ff5..5cf8b286 100644 --- a/lib/components/Search/redoc-search.ts +++ b/lib/components/Search/redoc-search.ts @@ -74,7 +74,7 @@ export class RedocSearch implements OnInit { item.pointers ); this.marker.remark(); - this.menu.activate(item.menuItem.flatIdx); + this.menu.activate(item.menuItem); this.menu.scrollToActive(); } diff --git a/lib/components/SideMenu/side-menu-items.html b/lib/components/SideMenu/side-menu-items.html index 0db93069..74e72a90 100644 --- a/lib/components/SideMenu/side-menu-items.html +++ b/lib/components/SideMenu/side-menu-items.html @@ -1,6 +1,9 @@