Skip to content

Commit 8bdd982

Browse files
authored
Prioritize request descriptions over rest-spec for endpoint descriptions (#2625)
1 parent 14150f3 commit 8bdd982

File tree

4 files changed

+1199
-1022
lines changed

4 files changed

+1199
-1022
lines changed

compiler/src/steps/add-description.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ import * as model from '../model/metamodel'
2222
import { JsonSpec } from '../model/json-spec'
2323

2424
/**
25-
* Adds the `description` field to every path and query property
26-
* from the rest-api-spec. If a description for a property
27-
* does not exists, the `description` key will not be added.
25+
* Adds the description from the rest-api-spec to every endpoint, path and query property
26+
* if not already present (i.e. missing in the TypeScript definition)
2827
*/
2928
export default async function addDescription (model: model.Model, jsonSpec: Map<string, JsonSpec>): Promise<model.Model> {
3029
for (const endpoint of model.endpoints) {
@@ -55,9 +54,9 @@ export default async function addDescription (model: model.Model, jsonSpec: Map<
5554
}
5655
}
5756

58-
if (spec.documentation.description != null) {
59-
requestDefinition.description = requestDefinition.description ?? spec.documentation.description
60-
}
57+
// An API endpoint is defined by an endpoint object (paths and http methods) and a request
58+
// type (parameters and structure).
59+
endpoint.description = requestDefinition.description ?? spec.documentation.description
6160
}
6261

6362
return model

0 commit comments

Comments
 (0)