import ts from "typescript" ; import type { OpenApi } from "../../../types" ; import { Factory } from "../../TsGenerator" ; import * as ConverterContext from "../ConverterContext" ; import * as ToTypeNode from "../toTypeNode" ; export const generatePropertySignature = ( entryPoint , currentPoint , factory , protocol , schema , context , converterContext ) : ts . PropertySignature => { return factory . PropertySignature . create ( { name : converterContext . escapePropertySignatureName ( protocol ) , optional : false , type : ToTypeNode . convert ( entryPoint , currentPoint , factory , schema , context , converterContext ) , comment : schema . description , } ) ; } ; export const generatePropertySignatures = ( entryPoint , currentPoint , factory , content , context , converterContext ) : ts . PropertySignature [ ] => { return Object . entries ( content ) . reduce < ts . PropertySignature [ ] > ( ( previous , [ protocol , mediaType ] ) => { if ( ! mediaType . schema ) { return previous ; } return previous . concat ( generatePropertySignature ( entryPoint , currentPoint , factory , protocol , mediaType . schema , context , converterContext ) ) ; } , [ ] ) ; } ; export const generateInterface = ( entryPoint , currentPoint , factory , name , content , context , converterContext ) : ts . InterfaceDeclaration => { return factory . InterfaceDeclaration . create ( { export : true , name , members : generatePropertySignatures ( entryPoint , currentPoint , factory , content , context , converterContext ) , } ) ; } ;