Merge pull request #3152 from slate-studio/master

Add operationId to be shown for each operation
This commit is contained in:
shockey
2017-06-06 11:36:48 -07:00
committed by GitHub
5 changed files with 25 additions and 7 deletions

View File

@@ -120,6 +120,7 @@ configUrl | Configs URL
parameterMacro | MUST be a function. Function to set default value to parameters. Accepts two arguments parameterMacro(operation, parameter). Operation and parameter are objects passed for context, both remain immutable parameterMacro | MUST be a function. Function to set default value to parameters. Accepts two arguments parameterMacro(operation, parameter). Operation and parameter are objects passed for context, both remain immutable
modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable modelPropertyMacro | MUST be a function. Function to set default values to each property in model. Accepts one argument modelPropertyMacro(property), property is immutable
docExpansion | Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default is 'list'. docExpansion | Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default is 'list'.
displayOperationId | Controls the display of operationId in operations list. The default is `false`.
### Plugins ### Plugins

View File

@@ -17,6 +17,8 @@ export default class Operation extends React.Component {
allowTryItOut: PropTypes.bool, allowTryItOut: PropTypes.bool,
displayOperationId: PropTypes.bool,
response: PropTypes.object, response: PropTypes.object,
request: PropTypes.object, request: PropTypes.object,
@@ -35,6 +37,7 @@ export default class Operation extends React.Component {
showSummary: true, showSummary: true,
response: null, response: null,
allowTryItOut: true, allowTryItOut: true,
displayOperationId: false,
} }
constructor(props, context) { constructor(props, context) {
@@ -108,6 +111,7 @@ export default class Operation extends React.Component {
response, response,
request, request,
allowTryItOut, allowTryItOut,
displayOperationId,
fn, fn,
getComponent, getComponent,
@@ -126,6 +130,7 @@ export default class Operation extends React.Component {
let produces = operation.get("produces") let produces = operation.get("produces")
let schemes = operation.get("schemes") let schemes = operation.get("schemes")
let parameters = getList(operation, ["parameters"]) let parameters = getList(operation, ["parameters"])
let operationId = operation.get("__originalOperationId")
const Responses = getComponent("responses") const Responses = getComponent("responses")
const Parameters = getComponent( "parameters" ) const Parameters = getComponent( "parameters" )
@@ -162,6 +167,8 @@ export default class Operation extends React.Component {
</div> </div>
} }
{ displayOperationId && operationId ? <span className="opblock-summary-path">{operationId}</span> : null }
{ {
(!security || !security.count()) ? null : (!security || !security.count()) ? null :
<AuthorizeOperationBtn authActions={ authActions } <AuthorizeOperationBtn authActions={ authActions }

View File

@@ -13,10 +13,6 @@ export default class Operations extends React.Component {
getConfigs: PropTypes.func.isRequired getConfigs: PropTypes.func.isRequired
}; };
static defaultProps = {
};
render() { render() {
let { let {
specSelectors, specSelectors,
@@ -36,7 +32,7 @@ export default class Operations extends React.Component {
const Collapse = getComponent("Collapse") const Collapse = getComponent("Collapse")
let showSummary = layoutSelectors.showSummary() let showSummary = layoutSelectors.showSummary()
let { docExpansion } = getConfigs() let { docExpansion, displayOperationId } = getConfigs()
return ( return (
<div> <div>
@@ -90,6 +86,8 @@ export default class Operations extends React.Component {
request={ request } request={ request }
allowTryItOut={allowTryItOut} allowTryItOut={allowTryItOut}
displayOperationId={displayOperationId}
specActions={ specActions } specActions={ specActions }
specSelectors={ specSelectors } specSelectors={ specSelectors }

View File

@@ -8,7 +8,7 @@ import { parseSeach, filterConfigs } from "core/utils"
const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion", const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
"apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl", "apisSorter", "operationsSorter", "supportedSubmitMethods", "dom_id", "defaultModelRendering", "oauth2RedirectUrl",
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro" ] "showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" ]
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
@@ -28,6 +28,7 @@ module.exports = function SwaggerUI(opts) {
validatorUrl: "https://online.swagger.io/validator", validatorUrl: "https://online.swagger.io/validator",
configs: {}, configs: {},
custom: {}, custom: {},
displayOperationId: false,
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance. // Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest. // Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.

View File

@@ -209,9 +209,10 @@ body
} }
.opblock-summary-path, .opblock-summary-path,
.opblock-summary-operation-id,
.opblock-summary-path__deprecated .opblock-summary-path__deprecated
{ {
font-size: 16px; font-size: 13px;
display: flex; display: flex;
@@ -247,6 +248,16 @@ body
text-decoration: line-through; text-decoration: line-through;
} }
.opblock-summary-path
{
font-size: 13px;
}
.opblock-summary-operation-id
{
font-size: 16px;
}
.opblock-summary-description .opblock-summary-description
{ {
font-size: 13px; font-size: 13px;