OpenAPITools / OpenAPITools/openapi-generator

[REQ] AsciiDoc generator should allow using AsciiDoc in field description

Open
#24,962 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

In an OpenAPI specification, it is common to use enumerations or lists to for instance describe the semantics of enum values

take for example the following field:

        vehicleType:
          type: integer
          enum: [ 1, 2, 3 ]
          x-enum-varnames: [ CAR_1, TRUCK_2, MOPED_3 ]
          description: |
            Type of Vehicle:
            
            * 1 - Automobile / Car
            * 2 - Truck
            * 3 - Moped / Motor-assisted bicycle

The AsciiDoc generator puts this multi-line description into a Table cell and for some reason assumes that table cell content can only be one-line in AsciiDoc. Hence it removes all the line-breaks, which looks like this:

| vehicleType
| 
| 
|  <<Integer>>  
| Type of Vehicle:  * 1 - Automobile / Car * 2 - Truck  * 3 - Moped / Motor-assisted bicycle
|  _Enum:_ 1, 2, 3

Unfortunately, when rendering this with AsciiDoc, it fill the table cells with a single floating text block, which is not readable at all. Removing the line breaks in essence broke the formatting and makes it impossible to use paragraphs, enumerations, lists, etc. which are all very useful for structuring information and making it readable.

If AsciiDoc table cells would indeed only support one-line content, then I could completely understand this. However, in AsciiDoc it is possible to turn a table cell into an AsciiDoc-cell by putting the letter 'a' before the '|' (Pipe symbol) like this:

| vehicleType
| 
| 
|  <<Integer>>  
a| Type of Vehicle:

  * 1 - Automobile / Car
  * 2 - Truck
  * 3 - Moped / Motor-assisted bicycle
|  _Enum:_ 1, 2, 3

This is rendered by AsciiDoc as a table cell with beautiful, multi-line content which can contain paragraphs, enumerations, lists and all the other benefits that full AsciiDoc support brings with it.

Describe the solution you'd like

My proposal is simple:

Do not remove the line breaks, but use an AsciiDoc cell (the one with the 'a' char before the pipe symbol) instead (at least for multi-line descriptions). This allows your users to make full use of what the AsciiDoc / Antora ecosystem has to offer instead of unneccessarily limiting them to one-line descriptions.

Describe alternatives you've considered

I wasted several hours trying to write a python script that put the line breaks back in at the correct locations in order to fix the formatting, but information that is removed cannot be recovered and the only right way to solve this issue is to fix the generator.

Additional context

How it is now:

Image

How it should be:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the AsciiDoc generator logic that emits field descriptions and table cells. Confirm how multiline descriptions are currently transformed, then ensure generated cells preserve the line breaks and use AsciiDoc-cell syntax for multiline content; done when lists and paragraphs render readably in the generated table.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.