@@ -60,36 +60,74 @@ export function getGroupedMessageDocs(docs: any): any {
6060}
6161
6262export function getGroupedMessageDocsJsonSchema ( docs : any ) : any {
63- if ( ! docs . definitions || typeof docs . definitions !== 'object' ) {
64- return { }
63+ console . log ( 'getGroupedMessageDocsJsonSchema - Raw docs:' , docs )
64+
65+ // Access messages from the correct path: properties.messages.items
66+ const messages = docs . properties ?. messages ?. items
67+ const definitions = docs . definitions || { }
68+
69+ if ( ! messages || ! Array . isArray ( messages ) ) {
70+ console . log ( 'No messages array found, falling back to definitions' )
71+ // Fallback to old structure if messages array doesn't exist
72+ if ( ! definitions || typeof definitions !== 'object' ) {
73+ console . log ( 'No definitions object found either' )
74+ return { grouped : { } , definitions : { } }
75+ }
76+
77+ // Convert definitions object to array format and group by InBound/OutBound prefix
78+ const grouped : any = { }
79+ Object . keys ( definitions ) . forEach ( ( methodName : string ) => {
80+ const schema = definitions [ methodName ]
81+
82+ // Determine category based on method name prefix
83+ let category = 'Uncategorized'
84+ if ( methodName . startsWith ( 'InBound' ) ) {
85+ category = 'Inbound Methods'
86+ } else if ( methodName . startsWith ( 'OutBound' ) ) {
87+ category = 'Outbound Methods'
88+ }
89+
90+ if ( ! grouped [ category ] ) {
91+ grouped [ category ] = [ ]
92+ }
93+
94+ grouped [ category ] . push ( {
95+ method_name : methodName ,
96+ category : category ,
97+ outbound_schema : schema ,
98+ inbound_schema : schema
99+ } )
100+ } )
101+
102+ console . log ( 'Grouped definitions result:' , grouped )
103+ return { grouped, definitions }
65104 }
66105
67- // Convert definitions object to array format and group by InBound/OutBound prefix
106+ // Group messages by adapter_implementation.group
107+ console . log ( 'Processing messages array' )
68108 const grouped : any = { }
69- Object . keys ( docs . definitions ) . forEach ( ( methodName : string ) => {
70- const schema = docs . definitions [ methodName ]
71-
72- // Determine category based on method name prefix
73- let category = 'Uncategorized'
74- if ( methodName . startsWith ( 'InBound' ) ) {
75- category = 'Inbound Methods'
76- } else if ( methodName . startsWith ( 'OutBound' ) ) {
77- category = 'Outbound Methods'
78- }
109+ messages . forEach ( ( message : any ) => {
110+ const category =
111+ message . adapter_implementation ?. group ?. replace ( '-' , '' ) . trim ( ) || 'Uncategorized'
79112
80113 if ( ! grouped [ category ] ) {
81114 grouped [ category ] = [ ]
82115 }
83116
117+ // Keep original schemas with $refs intact
84118 grouped [ category ] . push ( {
85- method_name : methodName ,
119+ method_name : message . process ,
86120 category : category ,
87- request_schema : schema ,
88- response_schema : schema
121+ description : message . description ,
122+ outbound_schema : message . outbound_schema ,
123+ inbound_schema : message . inbound_schema ,
124+ message_format : message . message_format
89125 } )
90126 } )
91127
92- return grouped
128+ console . log ( 'Grouped messages result:' , grouped )
129+ console . log ( 'Definitions:' , definitions )
130+ return { grouped, definitions }
93131}
94132
95133export async function cacheDoc ( cacheStorageOfMessageDocs : any ) : Promise < any > {
0 commit comments