From 5e65b0a503f95f9b68635465c359a7448c12b4ed Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 30 Oct 2024 11:18:13 -0400 Subject: [PATCH] Remove descriptions next to refs. --- tools/src/merger/OpenApiMerger.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/src/merger/OpenApiMerger.ts b/tools/src/merger/OpenApiMerger.ts index b1d8e9d81..57d80f8a2 100644 --- a/tools/src/merger/OpenApiMerger.ts +++ b/tools/src/merger/OpenApiMerger.ts @@ -54,6 +54,7 @@ export default class OpenApiMerger { this.#merge_namespaces() this.#sort_spec_keys() this.#add_defaults() + this.#fix_refs() this.#generate_global_params() this.#generate_superseded_ops() this._merged = true @@ -135,6 +136,21 @@ export default class OpenApiMerger { }) } + #fix_refs(obj: any = this._spec.components): void { + if (obj?.$ref !== undefined) { + if (obj?.description !== undefined) { + delete obj?.description + } + } + + for (const key in obj) { + var item = obj[key] + if (_.isObject(item) || _.isArray(item)) { + this.#fix_refs(item) + } + } + } + #add_defaults(): void { // Add default descriptions Object.entries(this._spec.components.responses as Document).forEach(([_path, response_item]) => {