File tree Expand file tree Collapse file tree 2 files changed +60
-40
lines changed Expand file tree Collapse file tree 2 files changed +60
-40
lines changed Original file line number Diff line number Diff line change @@ -44,15 +44,35 @@ const SPECIFICITY = {
44
44
absolutePath : 2 ,
45
45
} ;
46
46
47
+ /**
48
+ * @param {Schema | boolean } [schema]
49
+ * @returns {schema is Schema }
50
+ */
51
+ function hasType ( schema ) {
52
+ return ( schema && typeof schema !== 'boolean' ) || false ;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @param {Schema } schema
58
+ * @return {(property: string) => string }
59
+ */
47
60
function createPropertyFormatter ( schema ) {
48
61
const required = new Set ( schema . required || [ ] ) ;
62
+ /** @type {(property: string) => string } */
49
63
const format = ( property ) => property + ( required . has ( property ) ? '' : '?' ) ;
50
64
51
65
return function formatProperty ( property ) {
52
- const { type } =
53
- typeof schema . properties === 'object' && schema . properties !== null
54
- ? schema . properties [ property ] || { }
55
- : { } ;
66
+ let type ;
67
+
68
+ if ( typeof schema . properties === 'object' && schema . properties !== null ) {
69
+ const subSchema = schema . properties [ property ] ;
70
+
71
+ if ( hasType ( subSchema ) ) {
72
+ type = subSchema . type ;
73
+ }
74
+ }
75
+
56
76
const name = format ( property ) ;
57
77
58
78
if ( type ) {
You can’t perform that action at this time.
0 commit comments