@@ -20,6 +20,7 @@ const i18n = require('es2015-i18n-tag').default;
20
20
const ghslugger = require ( 'github-slugger' ) ;
21
21
const s = require ( './symbols' ) ;
22
22
const { gentitle } = require ( './formattingTools' ) ;
23
+ const { keyword } = require ( './keywords' ) ;
23
24
24
25
function build ( { header, links = { } , includeproperties = [ ] } = { } ) {
25
26
const formats = {
@@ -253,7 +254,7 @@ function build({ header, links = {}, includeproperties = [] } = {}) {
253
254
254
255
function nullable ( property ) {
255
256
const types = Array . isArray ( property . type ) ? property . type : [ property . type ] ;
256
- const nulltypes = flist ( filter ( types , mytype => mytype === ' null' ) ) ;
257
+ const nulltypes = flist ( filter ( types , mytype => mytype === keyword ` null` ) ) ;
257
258
if ( size ( nulltypes ) ) {
258
259
return text ( i18n `can be null` ) ;
259
260
}
@@ -299,16 +300,16 @@ function build({ header, links = {}, includeproperties = [] } = {}) {
299
300
function maketypefact ( definition , isarray = '' ) {
300
301
const alltypes = Array . isArray ( definition . type ) ? definition . type : [ definition . type ] ;
301
302
// filter out types that are null
302
- const realtypes = alltypes . filter ( mytype => mytype !== ' null' ) ;
303
+ const realtypes = alltypes . filter ( mytype => mytype !== keyword ` null` ) ;
303
304
// can the type be `null`
304
- const isnullable = alltypes . filter ( mytype => mytype === ' null' ) . length > 0 ;
305
+ const isnullable = alltypes . filter ( mytype => mytype === keyword ` null` ) . length > 0 ;
305
306
// is there only a single type or can there be multiple types
306
307
const singletype = realtypes . length <= 1 ;
307
308
const [ firsttype ] = realtypes ;
308
309
// is `null` the only allowed value
309
310
const nulltype = isnullable && realtypes . length === 0 ;
310
311
311
- const array = firsttype === ' array' ;
312
+ const array = firsttype === keyword ` array` ;
312
313
const merged = ! ! ( definition . allOf || definition . anyOf || definition . oneOf || definition . not ) ;
313
314
314
315
if ( array && definition . items ) {
@@ -333,7 +334,7 @@ function build({ header, links = {}, includeproperties = [] } = {}) {
333
334
if ( definition . title ) {
334
335
// if the type has a title, always create a link to the schema
335
336
return [ text ( ' (' ) , link ( `${ definition [ s . slug ] } .md` , '' , text ( definition . title ) ) , text ( ')' ) ] ;
336
- } else if ( ! singletype || firsttype === ' object' || merged ) {
337
+ } else if ( ! singletype || firsttype === keyword ` object` || merged ) {
337
338
return [ text ( ' (' ) , link ( `${ definition [ s . slug ] } .md` , '' , text ( i18n `Details` ) ) , text ( ')' ) ] ;
338
339
}
339
340
return [ ] ;
@@ -345,7 +346,7 @@ function build({ header, links = {}, includeproperties = [] } = {}) {
345
346
function makenullablefact ( definition ) {
346
347
const alltypes = Array . isArray ( definition . type ) ? definition . type : [ definition . type ] ;
347
348
// can the type be `null`
348
- const isnullable = alltypes . filter ( mytype => mytype === ' null' ) . length > 0 ;
349
+ const isnullable = alltypes . filter ( mytype => mytype === keyword ` null` ) . length > 0 ;
349
350
350
351
if ( isnullable ) {
351
352
return listItem ( paragraph ( text ( i18n `can be null` ) ) ) ;
@@ -452,7 +453,7 @@ function build({ header, links = {}, includeproperties = [] } = {}) {
452
453
453
454
if ( schema . enum ) {
454
455
console . log ( 'enum!' , schema [ s . filename ] , schema [ s . pointer ] ) ;
455
- const metas = schema [ ' meta:enum' ] || { } ;
456
+ const metas = schema [ keyword ` meta:enum` ] || { } ;
456
457
constraints . push ( paragraph ( [ strong ( text ( i18n `constant` ) ) , text ( ': ' ) , text ( i18n `the value of this property must be equal to one of the following values:` ) ] ) ) ;
457
458
constraints . push ( table ( 'left' , [
458
459
tableRow ( [
0 commit comments