@@ -98,11 +98,12 @@ function CRD() {
9898}
9999
100100function SchemaPart ( { key, property, parent, parentSlug } ) {
101- const [ props , propKeys , required , type , schema ] = useMemo ( ( ) => {
101+ const [ props , propKeys , required , type , schema , enumvals ] = useMemo ( ( ) => {
102102 let schema = property ;
103103 let props = property . Properties || { } ;
104104
105105 let type = property . Type ;
106+ let enumvals = null ;
106107 if ( type === 'array' ) {
107108 const itemsSchema = property . Items . Schema ;
108109 if ( itemsSchema . Type !== 'object' ) {
@@ -113,13 +114,18 @@ function SchemaPart({ key, property, parent, parentSlug }) {
113114 type = `[]object` ;
114115 }
115116 }
117+ if ( property . Enum ) {
118+ type = type + ': Enum' ;
119+ enumvals = property . Enum ;
120+ }
121+
116122 let propKeys = Object . keys ( props ) ;
117123
118124 let required = false ;
119125 if ( parent && parent . Required && parent . Required . includes ( key ) ) {
120126 required = true ;
121127 }
122- return [ props , propKeys , required , type , schema ]
128+ return [ props , propKeys , required , type , schema , enumvals ]
123129 } , [ parent , property ] ) ;
124130
125131 const slug = useMemo ( ( ) => slugify ( ( parentSlug ? `${ parentSlug } -` : '' ) + key ) , [ parentSlug , key ] ) ;
@@ -153,13 +159,22 @@ function SchemaPart({ key, property, parent, parentSlug }) {
153159 } ;
154160 } , [ ] ) ;
155161
162+ let enumHtml = '' ;
163+ if ( enumvals ) {
164+ enumHtml = enumvals . map ( v => html `< kbd class ="text-muted "> ${ v } </ kbd > ` ) ;
165+ }
166+
156167 return html `
157168 < details class ="collapse-panel " open ="${ isOpen } " onToggle =${ e => { setIsOpen ( e . target . open ) ; e . stopPropagation ( ) ; } } >
158169 < summary class ="collapse-header position-relative ">
159170 ${ key } < kbd class ="text-muted "> ${ type } </ kbd > ${ required ? html `< span class ="badge badge-primary "> required</ span > ` : '' }
160171 < button class ="btn btn-sm position-absolute right-0 top-0 m-5 copy-url z-10 " type ="button " data-clipboard-text ="${ fullLink } "> 🔗</ button >
161172 </ summary >
162173 < div id ="${ slug } " class ="collapse-content ">
174+ < div class ="property-description ">
175+ ${ enumvals ? html `Enum vals: ` : '' }
176+ ${ enumvals ? enumHtml : '' }
177+ </ div >
163178 ${ React . createElement ( "div" , { className : 'property-description' , dangerouslySetInnerHTML : { __html : getDescription ( property ) } } ) }
164179 ${ propKeys . length > 0 ? html `< br /> ` : '' }
165180 < div class ="collapse-group ">
0 commit comments