diff --git a/src/schema.ts b/src/schema.ts index 0f541608cd..7b1b1c6fcb 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -152,7 +152,7 @@ const processSchema = (schemas: Map, schema: Schema): void => { // Add to parent's children parent.children = - parent.children === undefined ? [title] : [...parent.children, title] + parent.children === undefined ? [title] : [...parent.children, title].sort() // Add to all ancestors' descendants and type enum let ancestor: Schema | null = parent @@ -160,16 +160,14 @@ const processSchema = (schemas: Map, schema: Schema): void => { ancestor.descendants = ancestor.descendants === undefined ? [title] - : [...ancestor.descendants, title] + : [...ancestor.descendants, title].sort() if ( + ancestor.title !== undefined && ancestor.properties !== undefined && ancestor.properties.type !== undefined && ancestor.properties.type.enum !== undefined ) { - ancestor.properties.type.enum = [ - ...ancestor.properties.type.enum, - title - ] + ancestor.properties.type.enum = [ancestor.title, ...ancestor.descendants] } ancestor = parentSchema(schemas, ancestor) } diff --git a/tests/__file_snapshots__/Thing.ts b/tests/__file_snapshots__/Thing.ts index ce9f407267..e1b2f17202 100644 --- a/tests/__file_snapshots__/Thing.ts +++ b/tests/__file_snapshots__/Thing.ts @@ -1,12 +1,10 @@ /** * The most generic type of item https://schema.org/Thing. */ -export interface Thing { - type: 'Thing' | 'CreativeWork' | 'Article' | 'MediaObject' | 'AudioObject' | 'Brand' | 'Code' | 'CodeBlock' | 'SoftwareSourceCode' | 'CodeChunk' | 'CodeExpr' | 'Collection' | 'ContactPoint' | 'Datatable' | 'DatatableColumn' | 'DatatableColumnSchema' | 'Mark' | 'Delete' | 'Emphasis' | 'Environment' | 'Heading' | 'ImageObject' | 'Include' | 'Link' | 'List' | 'ListItem' | 'Mount' | 'Organization' | 'Paragraph' | 'Person' | 'Product' | 'Quote' | 'QuoteBlock' | 'ResourceParameters' | 'SoftwareApplication' | 'SoftwareSession' | 'Strong' | 'Subscript' | 'Superscript' | 'Table' | 'TableCell' | 'TableRow' | 'ThematicBreak' | 'VideoObject' +export interface Thing extends Entity { + type: 'Thing' | 'Article' | 'AudioObject' | 'Brand' | 'Code' | 'CodeBlock' | 'CodeChunk' | 'CodeExpr' | 'Collection' | 'ContactPoint' | 'CreativeWork' | 'Datatable' | 'Environment' | 'ImageObject' | 'MediaObject' | 'Mount' | 'Organization' | 'Person' | 'Product' | 'ResourceParameters' | 'SoftwareApplication' | 'SoftwareSession' | 'SoftwareSourceCode' | 'Table' | 'VideoObject' alternateNames?: Array description?: string - id?: string - meta?: {[key: string]: any} name?: string url?: string }