Skip to content

Commit

Permalink
fixes #687 - deprecated parameter indicator for query and path params…
Browse files Browse the repository at this point in the history
…. also improve readability by removing strikthrough line elsewhere for deprecated attributes
  • Loading branch information
mrin9 committed Mar 26, 2022
1 parent 89ee825 commit 87af69e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
14 changes: 8 additions & 6 deletions src/components/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ export default class ApiRequest extends LitElement {
text-align: right;
line-height: var(--font-size-small);
}
.param-name{
.param-name {
color: var(--fg);
font-family: var(--font-mono);
}
.param-name.deprecated {
text-decoration: line-through;
color: var(--red);
}
.param-type{
color: var(--light-fg);
Expand Down Expand Up @@ -324,10 +324,12 @@ export default class ApiRequest extends LitElement {
}
const labelColWidth = 'read focused'.includes(this.renderStyle) ? '200px' : '160px';
tableRows.push(html`
<tr>
<tr title="${param.deprecated ? 'Deprecated' : ''}">
<td rowspan="${this.allowTry === 'true' ? '1' : '2'}" style="width:${labelColWidth}; min-width:100px;">
<div class="param-name">
${param.required ? html`<span style='color:var(--red)'>*</span>` : ''}${param.name}
<div class="param-name ${param.deprecated ? 'deprecated' : ''}" >
${param.deprecated ? html`<span style='color:var(--red);'></span>` : ''}
${param.required ? html`<span style='color:var(--red)'>*</span>` : ''}
${param.name}
</div>
<div class="param-type">
${paramSchema.type === 'array'
Expand Down Expand Up @@ -772,7 +774,7 @@ export default class ApiRequest extends LitElement {
const labelColWidth = 'read focused'.includes(this.renderStyle) ? '200px' : '160px';
const example = normalizeExamples((paramSchema.examples || paramSchema.example), paramSchema.type);
formDataTableRows.push(html`
<tr>
<tr title="${fieldSchema.deprecated ? 'Deprecated' : ''}">
<td style="width:${labelColWidth}; min-width:100px;">
<div class="param-name ${fieldSchema.deprecated ? 'deprecated' : ''}">
${fieldName}${(schema.required?.includes(fieldName) || fieldSchema.required) ? html`<span style='color:var(--red);'>*</span>` : ''}
Expand Down
15 changes: 9 additions & 6 deletions src/components/schema-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class SchemaTable extends LitElement {
width: 240px;
}
.key.deprecated .key-label {
text-decoration: line-through;
color: var(--red);
}
.table .key-type {
Expand Down Expand Up @@ -198,7 +198,7 @@ export default class SchemaTable extends LitElement {
return html`
${newSchemaLevel >= 0 && key
? html`
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}'>
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}' title="${data['::deprecated'] ? 'Deprecated' : ''}">
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
${(keyLabel || keyDescr)
? html`
Expand All @@ -214,8 +214,8 @@ export default class SchemaTable extends LitElement {
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>`
: keyLabel.endsWith('*')
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;"> ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${keyLabel === '::props' ? '' : keyLabel}</span>`
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel === '::props' ? '' : keyLabel}</span>`
}
${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
</div>
Expand Down Expand Up @@ -297,10 +297,13 @@ export default class SchemaTable extends LitElement {
</div>`;
}
return html`
<div class = "tr primitive">
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
<div class="td key ${deprecated}" style='padding-left:${leftPadding}px'>
${deprecated ? html`<span style='color:var(--red);'></span>` : ''}
${keyLabel?.endsWith('*')
? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
? html`
<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span>
<span style='color:var(--red);'>*</span>`
: key.startsWith('::OPTION')
? html`<span class='xxx-of-key'>${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
: html`${keyLabel ? html`<span class="key-label"> ${keyLabel}</span>` : html`<span class="xxx-of-descr">${schemaTitle}</span>`}`
Expand Down
12 changes: 7 additions & 5 deletions src/components/schema-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class SchemaTree extends LitElement {
max-width: 300px;
}
.key.deprecated .key-label {
text-decoration: line-through;
color: var(--red);
}
.open-bracket{
Expand Down Expand Up @@ -214,14 +214,15 @@ export default class SchemaTree extends LitElement {
}
if (typeof data === 'object') {
return html`
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}">
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}" title="${data['::deprecated'] ? 'Deprecated' : ''}">
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
? html`<span class='key-label xxx-of-key'>${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
? html`<span class='key-label xxx-of-key'> ${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
: keyLabel === '::props' || keyLabel === '::ARRAY~OF'
? ''
: schemaLevel > 0
? html`<span class="key-label" title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWrite === 'writeonly' ? 'Write-Only' : ''}">
${data['::deprecated'] ? '✗' : ''}
${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? html`<span style="color:var(--red)">*</span>` : ''}${readOrWrite === 'readonly' ? html` 🆁` : readOrWrite === 'writeonly' ? html` 🆆` : readOrWrite}:
</span>`
: ''
Expand Down Expand Up @@ -300,8 +301,9 @@ export default class SchemaTree extends LitElement {
}

return html`
<div class = "tr primitive">
<div class="td key ${deprecated}" style='min-width:${minFieldColWidth}px' >
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
<div class="td key ${deprecated}" style='min-width:${minFieldColWidth}px'>
${deprecated ? html`<span style='color:var(--red);'></span>` : ''}
${keyLabel.endsWith('*')
? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>:`
: key.startsWith('::OPTION')
Expand Down

0 comments on commit 87af69e

Please sign in to comment.