Skip to content

Commit

Permalink
Handle $ref type in formatType
Browse files Browse the repository at this point in the history
  • Loading branch information
mikachan committed Dec 20, 2022
1 parent 101ebcf commit 16b20dd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/api-docs/gen-theme-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,16 @@ const formatType = ( prop ) => {
let type = prop.type || '';

if ( prop.hasOwnProperty( 'anyOf' ) || prop.hasOwnProperty( 'oneOf' ) ) {
const types = prop.anyOf || prop.oneOf;
type = types.map( ( item ) => item.type ).join( ', ' );
const propTypes = prop.anyOf || prop.oneOf;
const types = [];

propTypes.forEach( ( item ) => {
if ( item.type ) types.push( item.type );
// $ref is always an object
if ( item.$ref ) types.push( 'object' );
} );

type = [ ...new Set( types ) ].join( ', ' );
}

return type;
Expand Down

1 comment on commit 16b20dd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3736435496
📝 Reported issues:

Please sign in to comment.