Skip to content

Commit a63bfb9

Browse files
committed
fixes #331 - one-of options style shouuld be uniform
1 parent 7104432 commit a63bfb9

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/components/schema-table.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default class SchemaTable extends LitElement {
139139
: ''
140140
}
141141
${data['::type'] === 'xxx-of-option' || prevKey.startsWith('::OPTION')
142-
? html`<span class='xxx-of-key'>${newPrevKey}</span>`
142+
? html`<span class='xxx-of-key' style='margin-left:-6px' >${newPrevKey}</span>`
143143
: newPrevKey.endsWith('*')
144144
? html`<span style="display:inline-block; margin-left:-6px;"> ${newPrevKey.substring(0, newPrevKey.length - 1)}</span><span style='color:var(--red);'>*</span>`
145145
: html`<span style="display:inline-block; margin-left:-6px;">${newPrevKey}</span>`
@@ -175,7 +175,9 @@ export default class SchemaTable extends LitElement {
175175
<div class='td key' style='padding-left:${leftPadding}px' >
176176
${newPrevKey.endsWith('*')
177177
? html`${newPrevKey.substring(0, newPrevKey.length - 1)}<span style='color:var(--red);'>*</span>`
178-
: newPrevKey
178+
: prevKey.startsWith('::OPTION')
179+
? html`<span class='xxx-of-key'>${newPrevKey}</span>`
180+
: html`${newPrevKey}`
179181
}
180182
</div>
181183
<div class='td key-type ${dataTypeCss}'>${prevDataType === 'array' ? `[${itemParts[0]}]` : itemParts[0]} <span style="font-family: var(--font-mono);">${itemParts[1]}</span> </div>

src/components/schema-tree.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ export default class SchemaTree extends LitElement {
185185
<div class='td key' style='min-width:${minFieldColWidth}px' >
186186
${newPrevKey.endsWith('*')
187187
? html`${newPrevKey.substring(0, newPrevKey.length - 1)}<span style='color:var(--red);'>*</span>`
188-
: newPrevKey
188+
: prevKey.startsWith('::OPTION')
189+
? html`<span class='xxx-of-key'>${newPrevKey}</span>`
190+
: html`${newPrevKey}`
189191
}:
190192
<span class='${dataTypeCss}'>
191-
${prevDataType === 'array' ? `[${itemParts[0]}]` : itemParts[0]}
193+
${prevDataType === 'array' ? `[${itemParts[0]}]` : `${itemParts[0]}`}
192194
<span>${itemParts[1]}</span>
193195
</span>
194196
</div>

src/styles/schema-styles.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export default css`
4040
}
4141
4242
.tr.xxx-of{
43-
color:var(--primary-color);
4443
border-top: 1px dotted var(--primary-color);
4544
}
4645

src/utils/schema-utils.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,20 +347,18 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
347347
}
348348
}
349349
// 2. Then show allof/anyof objects
350-
let i = 1;
351350
const objWithAnyOfProps = {};
352351
const xxxOf = schema.anyOf ? 'anyOf' : 'oneOf';
353-
schema[xxxOf].forEach((v) => {
352+
schema[xxxOf].forEach((v, index) => {
354353
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
355354
const partialObj = schemaInObjectNotation(v, {});
356-
objWithAnyOfProps[`::OPTION~${i}`] = partialObj;
355+
objWithAnyOfProps[`::OPTION~${index + 1}`] = partialObj;
357356
objWithAnyOfProps['::type'] = 'xxx-of-option';
358-
i++;
359357
} else if (v.type === 'array' || v.items) {
360358
const partialObj = [schemaInObjectNotation(v, {})];
361359
Object.assign(objWithAnyOfProps, partialObj);
362360
} else {
363-
const prop = `prop${Object.keys(objWithAnyOfProps).length}`;
361+
const prop = `::OPTION~${index + 1}`;
364362
objWithAnyOfProps[prop] = `${getTypeInfo(v).html}`;
365363
}
366364
});

0 commit comments

Comments
 (0)