Skip to content

Commit 881cd66

Browse files
delvedorgithub-actions[bot]
authored andcommitted
Add support for endpoint description (#719)
1 parent 85e47e8 commit 881cd66

File tree

3 files changed

+378
-0
lines changed

3 files changed

+378
-0
lines changed

compiler/model/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,15 @@ export function hoistRequestAnnotations (
518518
const knownRequestAnnotations = [
519519
'since', 'rest_spec_name', 'stability', 'visibility', 'behavior', 'class_serializer'
520520
]
521+
// in most of the cases the jsDocs comes in a single block,
522+
// but it can happen that the user defines multiple single line jsDoc.
523+
// We want to enforce a single jsDoc block.
524+
assert(jsDocs, jsDocs.length < 2, 'Use a single multiline jsDoc block instead of multiple single line blocks')
525+
526+
if (jsDocs.length === 1) {
527+
const description = jsDocs[0].getDescription()
528+
if (description.length > 0) request.description = description.trim()
529+
}
521530
const tags = parseJsDocTags(jsDocs)
522531
const apiName = tags.rest_spec_name
523532
// TODO (@typescript-eslint/strict-boolean-expressions) is no fun

compiler/steps/add-description.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export default async function addDescription (model: model.Model, jsonSpec: Map<
5454
}
5555
}
5656
}
57+
58+
if (spec.documentation.description != null) {
59+
requestDefinition.description = requestDefinition.description ?? spec.documentation.description
60+
}
5761
}
5862

5963
return model

0 commit comments

Comments
 (0)