@@ -29,7 +29,7 @@ import { JsonSpec } from '../model/json-spec'
29
29
export default async function addDescription ( model : model . Model , jsonSpec : Map < string , JsonSpec > ) : Promise < model . Model > {
30
30
for ( const endpoint of model . endpoints ) {
31
31
if ( endpoint . request == null ) continue
32
- const requestDefinition = getDefinition ( endpoint . request . name )
32
+ const requestDefinition = getDefinition ( endpoint . request )
33
33
const spec = jsonSpec . get ( endpoint . name )
34
34
assert ( spec , `Can't find the json spec for ${ endpoint . name } ` )
35
35
@@ -40,21 +40,32 @@ export default async function addDescription (model: model.Model, jsonSpec: Map<
40
40
} )
41
41
if ( definition ?. parts != null ) {
42
42
const { description } = definition . parts [ property . name ]
43
- property . description = description
43
+ if ( typeof description === 'string' ) {
44
+ property . description = property . description ?? description
45
+ }
46
+ }
47
+ }
48
+
49
+ if ( spec . params != null ) {
50
+ for ( const property of requestDefinition . query ) {
51
+ const param = spec . params [ property . name ]
52
+ if ( param != null && typeof param . description === 'string' ) {
53
+ property . description = property . description ?? param . description
54
+ }
44
55
}
45
56
}
46
57
}
47
58
48
59
return model
49
60
50
- function getDefinition ( name : string ) : model . Request {
61
+ function getDefinition ( request : model . TypeName ) : model . Request {
51
62
for ( const type of model . types ) {
52
63
if ( type . kind === 'request' ) {
53
- if ( type . name . name === name ) {
64
+ if ( type . name . name === request . name && type . name . namespace === request . namespace ) {
54
65
return type
55
66
}
56
67
}
57
68
}
58
- throw new Error ( `Can't find the request definiton for ${ name } ` )
69
+ throw new Error ( `Can't find the request definiton for ${ request . namespace } . ${ request . name } ` )
59
70
}
60
71
}
0 commit comments