import { Parameter , Property , SchemaContext } from "@autorest/codemodel" ; import { PropertySignatureStructure , StructureKind } from "ts-morph" ; import { getLanguageMetadata } from "../utils/languageHelpers" ; import { getElementType , getFormatDocs } from "./schemaHelpers" ; param property param importedModels returns export function getPropertySignature ( property , schemaUsage , importedModels = new Set < string > ( ) ) { const propertyLangMetadata = getLanguageMetadata ( property . language ) ; const propertyName = `"${ propertyLangMetadata . serializedName ?? ( property as Property ) . serializedName }"` ; if ( ! propertyName ) { throw new Error ( `Couldn't find name for property ${ JSON . stringify ( propertyLangMetadata ) }` ) ; } const description = getDocs ( property ) ; const type = getElementType ( property . schema , schemaUsage , importedModels ) ; return { name : propertyName , ... ( description && { docs : [ { description } ] } ) , hasQuestionToken : ! property . required , type , kind : StructureKind . PropertySignature } ; } export function getDocs ( property ) { const { description } = getLanguageMetadata ( property . language ) ; const docs = [ ] ; if ( description ) { docs . push ( description ) ; } const formatDocs = getFormatDocs ( property . schema ) ; if ( formatDocs ) { docs . push ( formatDocs ) ; } return docs . join ( "\n\n" ) ; }