@@ -175,44 +175,36 @@ export const convert: Convert = (
175175 return nullable ( factory , typeNode , ! ! schema . nullable ) ;
176176 }
177177 case "object" : {
178- if ( ! schema . properties ) {
179- return factory . TypeNode . create ( {
180- type : "object" ,
181- value : [ ] ,
182- } ) ;
183- }
184- let typeNode : ts . TypeNode ;
185178 const required : string [ ] = schema . required || [ ] ;
186- // https://swagger.io/docs/specification/data-models/dictionaries/#free-form
179+ // // https://swagger.io/docs/specification/data-models/dictionaries/#free-form
187180 if ( schema . additionalProperties === true ) {
188- typeNode = factory . TypeNode . create ( {
181+ return factory . TypeNode . create ( {
189182 type : schema . type ,
190183 value : [ ] ,
191184 } ) ;
192- } else {
193- const value : ts . PropertySignature [ ] = Object . entries ( schema . properties ) . map ( ( [ name , jsonSchema ] ) => {
194- return factory . PropertySignature . create ( {
195- name,
196- type : convert ( entryPoint , currentPoint , factory , jsonSchema , context , { parent : schema . properties } ) ,
197- optional : ! required . includes ( name ) ,
198- comment : typeof jsonSchema !== "boolean" ? jsonSchema . description : undefined ,
199- } ) ;
185+ }
186+ const value : ts . PropertySignature [ ] = Object . entries ( schema . properties || { } ) . map ( ( [ name , jsonSchema ] ) => {
187+ return factory . PropertySignature . create ( {
188+ name,
189+ type : convert ( entryPoint , currentPoint , factory , jsonSchema , context , { parent : schema . properties } ) ,
190+ optional : ! required . includes ( name ) ,
191+ comment : typeof jsonSchema !== "boolean" ? jsonSchema . description : undefined ,
200192 } ) ;
201- if ( schema . additionalProperties ) {
202- const additionalProperties = factory . IndexSignatureDeclaration . create ( {
203- name : "key" ,
204- type : convert ( entryPoint , currentPoint , factory , schema . additionalProperties , context , { parent : schema . properties } ) ,
205- } ) ;
206- return factory . TypeNode . create ( {
207- type : schema . type ,
208- value : [ ...value , additionalProperties ] ,
209- } ) ;
210- }
211- typeNode = factory . TypeNode . create ( {
193+ } ) ;
194+ if ( schema . additionalProperties ) {
195+ const additionalProperties = factory . IndexSignatureDeclaration . create ( {
196+ name : "key" ,
197+ type : convert ( entryPoint , currentPoint , factory , schema . additionalProperties , context , { parent : schema . properties } ) ,
198+ } ) ;
199+ return factory . TypeNode . create ( {
212200 type : schema . type ,
213- value,
201+ value : [ ... value , additionalProperties ] ,
214202 } ) ;
215203 }
204+ const typeNode = factory . TypeNode . create ( {
205+ type : schema . type ,
206+ value,
207+ } ) ;
216208 return nullable ( factory , typeNode , ! ! schema . nullable ) ;
217209 }
218210 default :
0 commit comments