@@ -113,9 +113,8 @@ export const Schema: React.FunctionComponent<Props> = ({
113113 </ >
114114 ) : (
115115 < span
116- className = { `break-anywhere text-sm ${
117- isProperty ? 'italic' : ''
118- } `}
116+ className = { `break-anywhere text-sm ${ isProperty ? 'italic' : ''
117+ } `}
119118 >
120119 { schemaName }
121120 </ span >
@@ -273,55 +272,48 @@ export const Schema: React.FunctionComponent<Props> = ({
273272
274273 { isCircular || ! isExpandable ? null : (
275274 < div
276- className = { `rounded p-4 py-2 border bg-gray-100 ${
277- reverse ? 'bg-gray-200' : ''
278- } ${ expanded ? 'block' : 'hidden' } `}
275+ className = { `rounded p-4 py-2 border bg-gray-100 ${ reverse ? 'bg-gray-200' : ''
276+ } ${ expanded ? 'block' : 'hidden' } `}
279277 >
280278 < SchemaProperties schema = { schema } />
281279 < SchemaItems schema = { schema } />
282280
283- { schema
284- . oneOf ( )
285- ?. map ( ( s , idx ) => (
286- < Schema
287- key = { idx }
288- schema = { s }
289- schemaName = { SchemaHelpers . applicatorSchemaName (
290- idx ,
291- 'Adheres to' ,
292- 'Or to' ,
293- s . title ( ) ?? s . id ( ) ,
294- ) }
295- />
296- ) ) }
297- { schema
298- . anyOf ( )
299- ?. map ( ( s , idx ) => (
300- < Schema
301- key = { idx }
302- schema = { s }
303- schemaName = { SchemaHelpers . applicatorSchemaName (
304- idx ,
305- 'Can adhere to' ,
306- 'Or to' ,
307- s . title ( ) ?? s . id ( ) ,
308- ) }
309- />
310- ) ) }
311- { schema
312- . allOf ( )
313- ?. map ( ( s , idx ) => (
314- < Schema
315- key = { idx }
316- schema = { s }
317- schemaName = { SchemaHelpers . applicatorSchemaName (
318- idx ,
319- 'Consists of' ,
320- 'And of' ,
321- s . title ( ) ?? s . id ( ) ,
322- ) }
323- />
324- ) ) }
281+ { schema . oneOf ( ) ?. map ( ( s , idx ) => (
282+ < Schema
283+ key = { idx }
284+ schema = { s }
285+ schemaName = { SchemaHelpers . applicatorSchemaName (
286+ idx ,
287+ 'Adheres to' ,
288+ 'Or to' ,
289+ s . title ( ) ?? s . id ( ) ,
290+ ) }
291+ />
292+ ) ) }
293+ { schema . anyOf ( ) ?. map ( ( s , idx ) => (
294+ < Schema
295+ key = { idx }
296+ schema = { s }
297+ schemaName = { SchemaHelpers . applicatorSchemaName (
298+ idx ,
299+ 'Can adhere to' ,
300+ 'Or to' ,
301+ s . title ( ) ?? s . id ( ) ,
302+ ) }
303+ />
304+ ) ) }
305+ { schema . allOf ( ) ?. map ( ( s , idx ) => (
306+ < Schema
307+ key = { idx }
308+ schema = { s }
309+ schemaName = { SchemaHelpers . applicatorSchemaName (
310+ idx ,
311+ 'Consists of' ,
312+ 'And of' ,
313+ s . title ( ) ?? s . id ( ) ,
314+ ) }
315+ />
316+ ) ) }
325317 { schema . not ( ) && (
326318 < Schema schema = { schema . not ( ) } schemaName = "Cannot adhere to:" />
327319 ) }
@@ -377,15 +369,20 @@ interface SchemaPropertiesProps {
377369const SchemaProperties : React . FunctionComponent < SchemaPropertiesProps > = ( {
378370 schema,
379371} ) => {
380- const properties = schema . properties ( ) ?? { } ;
381- const patternProperties = schema . patternProperties ( ) ?? { } ;
372+ const properties = Object . entries ( schema . properties ( ) ?? { } ) ;
373+ const patternProperties = Object . entries ( schema . patternProperties ( ) ?? { } ) ;
374+
375+ if ( ! properties . length && ! patternProperties . length ) {
376+ return null ;
377+ }
382378
383379 const required = schema . required ( ) ?? [ ] ;
384380
385381 return (
386382 < >
387- { Object . entries ( properties ) . map ( ( [ propertyName , property ] ) => (
383+ { properties . map ( ( [ propertyName , property ] ) => (
388384 < Schema
385+ key = { propertyName }
389386 schema = { property }
390387 schemaName = { propertyName }
391388 required = { required . includes ( propertyName ) }
@@ -395,21 +392,19 @@ const SchemaProperties: React.FunctionComponent<SchemaPropertiesProps> = ({
395392 propertyName ,
396393 schema ,
397394 ) }
395+ />
396+ ) ) }
397+
398+ { patternProperties . map ( ( [ propertyName , property ] ) => (
399+ < Schema
398400 key = { propertyName }
401+ schema = { property }
402+ schemaName = { propertyName }
403+ isPatternProperty
404+ isProperty
405+ isCircular = { property . isCircular ( ) }
399406 />
400407 ) ) }
401- { Object . entries ( patternProperties ?? { } ) . map (
402- ( [ propertyName , property ] ) => (
403- < Schema
404- schema = { property }
405- schemaName = { propertyName }
406- isPatternProperty
407- isProperty
408- isCircular = { property . isCircular ( ) }
409- key = { propertyName }
410- />
411- ) ,
412- ) }
413408 </ >
414409 ) ;
415410} ;
0 commit comments