@@ -222,7 +222,10 @@ function defineEnum(
222222 } ;
223223}
224224
225- function parseInterfaceProperties ( properties : { [ propertyName : string ] : Schema } = { } ) : Property [ ] {
225+ function parseInterfaceProperties (
226+ properties : { [ propertyName : string ] : Schema } = { } ,
227+ requiredProps : string [ ] = [ ] ,
228+ ) : Property [ ] {
226229 return Object . entries < Schema > ( properties ) . map (
227230 ( [ propName , propSchema ] : [ string , Schema ] ) => {
228231 const isArray = / ^ a r r a y $ / i. test ( propSchema . type || '' ) ;
@@ -240,6 +243,7 @@ function parseInterfaceProperties(properties: { [propertyName: string]: Schema }
240243 isArray,
241244 isDictionary : propSchema . additionalProperties ,
242245 isRef : ! ! parseReference ( propSchema ) ,
246+ isRequired : requiredProps . includes ( propName ) ,
243247 name : / ^ [ A - Z a - z _ $ ] [ \w $ ] * $ / . test ( propName ) ? propName : `'${ propName } '` ,
244248 description : replaceNewLines ( propSchema . description ) ,
245249 type : typescriptType . replace ( '[]' , '' ) ,
@@ -290,10 +294,13 @@ function defineInterface(schema: Schema, definitionKey: string): Definition {
290294 ? toCamelCase ( dereferenceType ( ( schema . allOf . find ( allOfSchema => ! ! allOfSchema . $ref ) || { } ) . $ref ) , false )
291295 : undefined ;
292296 const allOfProps : Schema = schema . allOf ? schema . allOf . reduce ( ( props , allOfSchema ) => ( { ...props , ...allOfSchema . properties } ) , { } ) : { } ;
293- const properties : Property [ ] = parseInterfaceProperties ( {
294- ...schema . properties ,
295- ...allOfProps ,
296- } as { [ propertyName : string ] : Schema } ) ;
297+ const properties : Property [ ] = parseInterfaceProperties (
298+ {
299+ ...schema . properties ,
300+ ...allOfProps ,
301+ } as { [ propertyName : string ] : Schema } ,
302+ schema . required ,
303+ ) ;
297304
298305 return {
299306 name : name ,
0 commit comments