Skip to content

Allow description in schema elements in additon to the description on the level above.#284

Closed
Xarno wants to merge 1 commit intoAuthress-Engineering:release/2.2from
Xarno:release/2.2
Closed

Allow description in schema elements in additon to the description on the level above.#284
Xarno wants to merge 1 commit intoAuthress-Engineering:release/2.2from
Xarno:release/2.2

Conversation

@Xarno
Copy link
Copy Markdown
Contributor

@Xarno Xarno commented Jul 22, 2025

The kotlin openapi generator put the description for query parameter inside the schema element. So this change allows to render the text from there.

Example:
The change adds the text marked by blue arrows and maintains the purple one.
Render more texts

@wparad
Copy link
Copy Markdown
Member

wparad commented Jul 22, 2025

Before we make any change, we'll need to validate that this indeed valid syntax according to the OAS 3.1+? Can you link me to where schema.description is defined and where its semantics are specified, so that we can be sure this is the appropriate implementation.

@Xarno
Copy link
Copy Markdown
Contributor Author

Xarno commented Jul 23, 2025

Thanks for the pointer to look again and sorry to have bothered you.
It turn's out that not the @Schema annotation of the generator needs to be used at a parameter — even if it have a description field — but the @Parameter annotation. Then the text moves from the „blue“ position to the „purple“ one and is rendered.

That we have sometimes two texts is our problem, and I have a way to join them if needed.

@Xarno Xarno closed this Jul 23, 2025
@wparad
Copy link
Copy Markdown
Member

wparad commented Jul 23, 2025

For what it's worth (as well as anyone else that sees this in the future). You can dynamically make adjustments to your spec using this library, that go into affect before render by doing something like this using the onSpecLoaded hook for the library:

recursiveFindAndUpdateAllDescriptionFields(param) {
  if (!param || typeof param !== 'object') {
    return;
  }

  if (Array.isArray(param)) {
    param.map(p => recursiveFindAndUpdateAllDescriptionFields(p));
    return;
  }

  if (param.description && param.schema.description) {
    param.descrption += `<br />${param.schema.description}`;
    return;
  }
}

onSpecLoaded(data) {
  recursiveFindAndUpdateAllDescriptionFields(data.detail);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants