Skip to content

Commit

Permalink
Resolve bug bcherny#637
Browse files Browse the repository at this point in the history
Incorrect Generation if oneOf is used mixed with properties
  • Loading branch information
martineaus83 authored Oct 2, 2024
1 parent 118d6a8 commit fda843f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,27 @@ function declareNamedTypes(ast: AST, options: Options, rootASTName: string, proc
case 'ENUM':
return ''
case 'INTERFACE':
return getSuperTypesAndParams(ast)
const superclass = getSuperTypesAndParams(ast)
.map(
ast =>
(ast.standaloneName === rootASTName || options.declareExternallyReferenced) &&
declareNamedTypes(ast, options, rootASTName, processed),
)
.filter(Boolean)
.join('\n')
.join('\n');
const code = [
hasStandaloneName(ast) ? generateStandaloneType(ast, options) : undefined,
ast.params
.map(ast => declareNamedTypes(ast, options, rootASTName, processed))
.filter(Boolean)
.join('\n'),
'spreadParam' in ast && ast.spreadParam
? declareNamedTypes(ast.spreadParam, options, rootASTName, processed)
: undefined,
]
.filter(Boolean)
.join('\n');
return superclass+"\n"+code;
case 'INTERSECTION':
case 'TUPLE':
case 'UNION':
Expand Down

0 comments on commit fda843f

Please sign in to comment.