@@ -52,14 +52,22 @@ export function transformSchemaObjMap(obj: Record<string, any>, options: Transfo
5252}
5353
5454/** make sure all required fields exist **/
55- export function addRequiredProps ( properties : Record < string , any > , required : Set < string > ) : string [ ] {
55+ export function addRequiredProps (
56+ properties : Record < string , any > ,
57+ required : Set < string > ,
58+ additionalProperties : any ,
59+ options : TransformSchemaObjOptions
60+ ) : string [ ] {
5661 const missingRequired = [ ...required ] . filter ( ( r : string ) => ! ( r in properties ) ) ;
5762 if ( missingRequired . length == 0 ) {
5863 return [ ] ;
5964 }
6065 let output = "" ;
66+
67+ const valueType = additionalProperties ? transformSchemaObj ( additionalProperties , options ) : "unknown" ;
68+
6169 for ( const r of missingRequired ) {
62- output += `${ r } : unknown ;\n` ;
70+ output += `${ r } : ${ valueType } ;\n` ;
6371 }
6472 return [ `{\n${ output } }` ] ;
6573}
@@ -131,7 +139,12 @@ export function transformSchemaObj(node: any, options: TransformSchemaObjOptions
131139 }
132140 case "object" : {
133141 const isAnyOfOrOneOfOrAllOf = "anyOf" in node || "oneOf" in node || "allOf" in node ;
134- const missingRequired = addRequiredProps ( node . properties || { } , node . required || [ ] ) ;
142+ const missingRequired = addRequiredProps (
143+ node . properties || { } ,
144+ node . required || [ ] ,
145+ node . additionalProperties ,
146+ options
147+ ) ;
135148 // if empty object, then return generic map type
136149 if (
137150 ! isAnyOfOrOneOfOrAllOf &&
0 commit comments