import { codeBlock , documentationBlock , unixEOL } from '@sap-cloud-sdk/util' ; import { OpenApiPersistedSchema } from '../openapi-types' ; import { collectRefs , getSchemaPropertiesDocumentation } from '../schema-util' ; import { serializeSchema } from './schema' ; import { Import , serializeImports } from './imports' ; param namedSchema returns internal export function schemaFile ( namedSchema ) { const imports = serializeImports ( getImports ( namedSchema ) ) ; return codeBlock `    
    ${ imports }
    ${ schemaDocumentation ( namedSchema ) }
    export type ${ namedSchema . schemaName } = ${ serializeSchema ( namedSchema . schema ) };
  ` ; } function getImports ( namedSchema ) { return collectRefs ( namedSchema . schema ) . filter ( ref => ref . schemaName !== namedSchema . schemaName ) . map ( ref => ( { names : [ ref . schemaName ] , typeOnly : true , moduleIdentifier : `./${ ref . fileName }` } ) ) ; } internal export function schemaDocumentation ( schema ) { const lines = [ schema . description || `Representation of the '${ schema . schemaName }' schema.` , ... getSchemaPropertiesDocumentation ( schema . schemaProperties ) ] ; return documentationBlock `${ lines . join ( unixEOL ) }` ; }