Skip to content

Commit

Permalink
Prioritize request descriptions over rest-spec for endpoint descripti…
Browse files Browse the repository at this point in the history
…ons (#2625)
  • Loading branch information
swallez authored Jun 20, 2024
1 parent 14150f3 commit 8bdd982
Show file tree
Hide file tree
Showing 4 changed files with 1,199 additions and 1,022 deletions.
11 changes: 5 additions & 6 deletions compiler/src/steps/add-description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import * as model from '../model/metamodel'
import { JsonSpec } from '../model/json-spec'

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

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

return model
Expand Down
Loading

0 comments on commit 8bdd982

Please sign in to comment.