Skip to content

Commit 43d87ce

Browse files
committed
color coded star for required fields
1 parent 8ef0166 commit 43d87ce

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

β€Žsrc/components/schema-tree.jsβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ export default class SchemaTree extends LitElement {
152152
<span class="any-of-one-of" >${key.replace('_', ' ')}</span>`
153153
: key.startsWith('OPTION')
154154
? html`<span class="any-of-one-of" >${key.replace('OPTION_', ' ')}</span>`
155-
: html`${key}:`
155+
: key.endsWith('*')
156+
? html`${key.substring(0, key.length - 1)}<span style='color:var(--delete-color)'>*</span>:`
157+
: html`${key}:`
156158
: ''
157159
}
158160
</span>

β€Žsrc/utils/common-utils.jsβ€Ž

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function copyToClipboard(elId) {
2727
}
2828

2929
/* Generates an schema object containing type and constraint info */
30-
export function getTypeInfo(schema, overrideAttributes = null) {
30+
export function getTypeInfo(schema) {
3131
if (!schema) {
3232
return;
3333
}
@@ -77,9 +77,9 @@ export function getTypeInfo(schema, overrideAttributes = null) {
7777
if (schema.minimum !== undefined && schema.maximum !== undefined) {
7878
returnObj.constrain = `${schema.exclusiveMinimum ? '>' : ''}${schema.minimum}\u00a0\u22ef\u00a0${schema.exclusiveMaximum ? '<' : ''}\u00a0${schema.maximum}`;
7979
} else if (schema.minimum !== undefined && schema.maximum === undefined) {
80-
returnObj.constrain = `${schema.exclusiveMinimum ? '>' : 'β‰₯'}${schema.minimum}`;
80+
returnObj.constrain = `${schema.exclusiveMinimum ? '>' : '>='}${schema.minimum}`;
8181
} else if (schema.minimum === undefined && schema.maximum !== undefined) {
82-
returnObj.constrain = `${schema.exclusiveMaximum ? '<' : '≀'}${schema.maximum}`;
82+
returnObj.constrain = `${schema.exclusiveMaximum ? '<' : '<='}${schema.maximum}`;
8383
}
8484
if (schema.multipleOf !== undefined) {
8585
returnObj.constrain = `(multiple of ${schema.multipleOf})`;
@@ -88,36 +88,25 @@ export function getTypeInfo(schema, overrideAttributes = null) {
8888
if (schema.minLength !== undefined && schema.maxLength !== undefined) {
8989
returnObj.constrain = `(${schema.minLength} to ${schema.maxLength} chars)`;
9090
} else if (schema.minLength !== undefined && schema.maxLength === undefined) {
91-
returnObj.constrain = `β‰₯ ${schema.minLength} chars`;
91+
returnObj.constrain = `min ${schema.minLength} chars`;
9292
} else if (schema.minLength === undefined && schema.maxLength !== undefined) {
93-
returnObj.constrain = `≀${schema.maxLength} chars`;
94-
}
95-
}
96-
97-
if (overrideAttributes) {
98-
if (overrideAttributes.readOnly) {
99-
returnObj.readOnly = 'πŸ†';
100-
}
101-
if (overrideAttributes.writeOnly) {
102-
returnObj.writeOnly = 'πŸ††';
103-
}
104-
if (overrideAttributes.deprecated) {
105-
returnObj.deprecated = '❌';
93+
returnObj.constrain = `max ${schema.maxLength} chars`;
10694
}
10795
}
10896

10997
// ${returnObj.readOnly}${returnObj.writeOnly}${returnObj.deprecated}\u00a0
11098
let html = `${returnObj.format ? returnObj.format : returnObj.type}`;
99+
let readWriteConstraints = '';
111100
if (returnObj.readOnly) {
112-
html += ' πŸ†';
101+
readWriteConstraints += 'πŸ†';
113102
}
114103
if (returnObj.writeOnly) {
115-
html += ' πŸ††';
104+
readWriteConstraints += 'πŸ††';
116105
}
117106
if (returnObj.deprecated) {
118-
html += ' ❌';
107+
readWriteConstraints += '❌';
119108
}
120-
html += `~|~${returnObj.constrain}~|~${(returnObj.type === 'enum' ? returnObj.allowedValues : returnObj.pattern)}~|~${returnObj.description}`;
109+
html += `~|~${readWriteConstraints} ${returnObj.constrain}~|~${(returnObj.type === 'enum' ? returnObj.allowedValues : returnObj.pattern)}~|~${returnObj.description}`;
121110
returnObj.html = html;
122111
return returnObj;
123112
}

0 commit comments

Comments
Β (0)