File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
reverse_engineering/helpers/adaptJsonSchema Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,30 @@ const convertToString = (jsonSchema) => {
77 } ) ;
88} ;
99
10+ const convertMultipleTypeToType = jsonSchema => {
11+ const type = jsonSchema . type . find ( item => item !== 'null' ) ;
12+
13+ if ( ! type ) {
14+ return convertToString ( jsonSchema ) ;
15+ } else if ( ! jsonSchema . type . includes ( 'null' ) ) {
16+ return {
17+ ...jsonSchema ,
18+ type
19+ }
20+ }
21+
22+ return {
23+ ...jsonSchema ,
24+ type,
25+ nullable : true
26+ }
27+ }
28+
1029const adaptJsonSchema = ( jsonSchema ) => {
1130 return mapJsonSchema ( jsonSchema , ( jsonSchemaItem ) => {
12- if ( jsonSchemaItem . type !== 'null' ) {
31+ if ( Array . isArray ( jsonSchemaItem . type ) ) {
32+ return convertMultipleTypeToType ( jsonSchemaItem ) ;
33+ } else if ( jsonSchemaItem . type !== 'null' ) {
1334 return jsonSchemaItem ;
1435 }
1536
You can’t perform that action at this time.
0 commit comments