Skip to content

Commit

Permalink
feat(render/parameters): display enums, defaults, and examples when n…
Browse files Browse the repository at this point in the history
…ot in TIO mode
  • Loading branch information
dedece35 authored and shockey committed Jan 6, 2018
1 parent 12a9fbc commit a47da98
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/core/components/parameter-row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ export default class ParameterRow extends Component {
let value = parameter ? parameter.get("value") : ""
let extensions = getExtensions(param)


let paramItems // undefined
let paramItemsEnum // undefined
let isDisplayParamItemsEnum = false
if ( param !== undefined ) {
paramItems = param.get("items")
}
if ( paramItems !== undefined ) {
paramItemsEnum = param.get("items").get("enum")
}
if ( paramItemsEnum !== undefined ) {
if (paramItemsEnum.size > 0) {
isDisplayParamItemsEnum = true
}
}

// Default and Example Value for readonly doc
let paramDefaultValue // undefined
let paramExample // undefined
if ( param !== undefined ) {
paramDefaultValue = param.get("default")
paramExample = param.get("example")
}

if (isDisplayParamItemsEnum) { // if we have an array, default value is in "items"
paramDefaultValue = paramItems.get("default")
}

return (
<tr>
<td className="col parameters-col_name">
Expand All @@ -125,6 +153,25 @@ export default class ParameterRow extends Component {

<td className="col parameters-col_description">
<Markdown source={ param.get("description") }/>

{ (bodyParam || !isExecute) && isDisplayParamItemsEnum ?
<Markdown source={
"<i>Available values</i> : " + paramItemsEnum.map(function(item) {
return item
}).toArray()}/>
: null
}

{ (bodyParam || !isExecute) && paramDefaultValue !== undefined ?
<Markdown source={"<i>Default value</i> : " + paramDefaultValue}/>
: null
}

{ (bodyParam || !isExecute) && paramExample !== undefined ?
<Markdown source={"<i>Example</i> : " + paramExample}/>
: null
}

{(isFormData && !isFormDataSupported) && <div>Error: your browser does not support FormData</div>}

{ bodyParam || !isExecute ? null
Expand Down

0 comments on commit a47da98

Please sign in to comment.