From 41e4d98a4cad9fda81942f455268fa75ab1d46ab Mon Sep 17 00:00:00 2001 From: Jesse Mandel Date: Mon, 26 Jun 2017 22:49:57 -0700 Subject: [PATCH] Properly added name config Now access it through getConfigs Documented it in README --- README.md | 3 ++- src/core/index.js | 2 +- src/plugins/topbar/topbar.jsx | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8c4322fc..777ab2dc 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ Parameter Name | Description --- | --- url | The url pointing to API definition (normally `swagger.json` or `swagger.yaml`). Will be ignored if `urls` or `spec` is used. urls | An array of API definition objects (`{url: "", name: ""}`) used by Topbar plugin. When used and Topbar plugin is enabled, the `url` parameter will not be parsed. +name | When using `urls`, you can use this parameter select an initial spec instead of defaulting to the first one. Useful as a query parameter to link to a specific spec. spec | A JSON object describing the OpenAPI Specification. When used, the `url` parameter will not be parsed. This is useful for testing manually-generated specifications without hosting them. validatorUrl | By default, Swagger-UI attempts to validate specs against swagger.io's online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). Setting it to `null` will disable validation. dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger. @@ -144,7 +145,7 @@ displayOperationId | Controls the display of operationId in operations list. The ### Plugins #### Topbar plugin -Topbar plugin enables top bar with input for spec path and explore button or a dropdown if `urls` is used. When using the dropdown, a query parameter `name` can be passed to select that API. By default the plugin is enabled, and to disable it you need to remove Topbar plugin from presets in `src/standalone/index.js`: +Topbar plugin enables top bar with input for spec path and explore button or a dropdown if `urls` is used. By default the plugin is enabled, and to disable it you need to remove Topbar plugin from presets in `src/standalone/index.js`: ``` let preset = [ diff --git a/src/core/index.js b/src/core/index.js index 1d73f22e..e01f4451 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -6,7 +6,7 @@ import ApisPreset from "core/presets/apis" import * as AllPlugins from "core/plugins/all" import { parseSeach, filterConfigs } from "core/utils" -const CONFIGS = [ "url", "urls", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion", +const CONFIGS = [ "url", "urls", "name", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion", "apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl", "showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" ] diff --git a/src/plugins/topbar/topbar.jsx b/src/plugins/topbar/topbar.jsx index 548a2209..5e013d72 100644 --- a/src/plugins/topbar/topbar.jsx +++ b/src/plugins/topbar/topbar.jsx @@ -2,7 +2,6 @@ import React, { PropTypes } from "react" //import "./topbar.less" import Logo from "./logo_small.png" -import { parseSeach } from "core/utils" export default class Topbar extends React.Component { @@ -37,10 +36,11 @@ export default class Topbar extends React.Component { } componentWillMount() { - const urls = this.props.getConfigs().urls || [] + const configs = this.props.getConfigs() + const urls = configs.urls || [] if(urls && urls.length) { - let selectedName = parseSeach().name + let selectedName = configs.name if(selectedName) { urls.forEach((spec, i) => {