Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize request descriptions over rest-spec for endpoint descriptions #2625

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading