@@ -32,7 +32,6 @@ import {
3232 TypeAliasDeclaration
3333} from 'ts-morph'
3434import * as model from './metamodel'
35- import { JsonSpec } from './json-spec'
3635import {
3736 assert ,
3837 customTypes ,
@@ -57,28 +56,10 @@ import {
5756 mediaTypeToStringArray
5857} from './utils'
5958
60- export function compileEndpoints ( jsonSpec : Map < string , JsonSpec > ) : Record < string , model . Endpoint > {
61- // Create endpoints and merge them with
62- // the recorded mappings if present.
63- const map = { }
64- for ( const [ api , spec ] of jsonSpec . entries ( ) ) {
65- map [ api ] = {
66- name : api ,
67- description : null ,
68- docUrl : null ,
69- request : null ,
70- requestBodyRequired : false ,
71- response : null ,
72- urls : [ ]
73- }
74- map [ api ] . availability = { }
75- }
76- return map
77- }
78-
79- export function compileSpecification ( endpointMappings : Record < string , model . Endpoint > , specsFolder : string , outputFolder : string ) : model . Model {
59+ export function compileSpecification ( specsFolder : string , outputFolder : string ) : model . Model {
8060 const tsConfigFilePath = join ( specsFolder , 'tsconfig.json' )
8161 const project = new Project ( { tsConfigFilePath } )
62+ const endpointMappings : Record < string , model . Endpoint > = { }
8263
8364 verifyUniqueness ( project )
8465
@@ -117,9 +98,6 @@ export function compileSpecification (endpointMappings: Record<string, model.End
11798 definedButNeverUsed . join ( '\n' ) ,
11899 { encoding : 'utf8' , flag : 'w' }
119100 )
120- for ( const endpoint of Object . values ( endpointMappings ) ) {
121- model . endpoints . push ( endpoint )
122- }
123101
124102 // Visit all class, interface, enum and type alias definitions
125103 for ( const declaration of declarations . classes ) {
@@ -141,6 +119,11 @@ export function compileSpecification (endpointMappings: Record<string, model.End
141119 // Sort the types in alphabetical order
142120 sortTypeDefinitions ( model . types )
143121
122+ const sortedEndpointKeys = Object . keys ( endpointMappings ) . sort ( )
123+ for ( const key of sortedEndpointKeys ) {
124+ model . endpoints . push ( endpointMappings [ key ] )
125+ }
126+
144127 return model
145128}
146129
@@ -191,8 +174,8 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
191174 throw new Error ( `Cannot find url template for ${ namespace } , very likely the specification folder does not follow the rest-api-spec` )
192175 }
193176
194- if ( type . description ) {
195- mapping . description = type . description || ''
177+ if ( type . description !== '' && type . description !== null && type . description !== undefined ) {
178+ mapping . description = type . description
196179 }
197180
198181 let pathMember : Node | null = null
0 commit comments