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

[BUG][dart][dart-dio] Dart Docs Improperly Formatted #21010

Open
2 of 6 tasks
PvtPuddles opened this issue Apr 1, 2025 · 0 comments
Open
2 of 6 tasks

[BUG][dart][dart-dio] Dart Docs Improperly Formatted #21010

PvtPuddles opened this issue Apr 1, 2025 · 0 comments

Comments

@PvtPuddles
Copy link

PvtPuddles commented Apr 1, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am having trouble getting basic doc formatting to work with the Dart code generator.

It seems that newlines are not being respected in multi line strings

Additional html features don't work (such as the <b> tag), but I am considering that out of scope for this issue.

openapi-generator version

OpenAPI Version 3.1.0

OpenAPI declaration file content or url
openapi: 3.1.0

# Case 1: Description is displayed on the same line as the summary
paths:
  /api/v1/location/{location_id}:
    get:
      summary: Specific Authorized Location
      description: >
        Retrieve data for a single location identified by the `location_id` provided, 
        if the user is authorized to access the location.
      operationId: getLocation
      parameters: [ ... ]
      responses: [ ... ]

# Case 2: Newlines are ignored
components:
  schemas:
    Alert:
      type: object
      description: >
        An alert indicating that something is not behaving as expected
      properties:
        severity:
          type: string
          # See: https://github.com/OAI/OpenAPI-Specification/issues/348
          description: |
            The severity of the alert.
            
            * `alarm` - Action is urgently required.
            * `alert` - Actions should be taken to fix the problem.
            * `intrigue` - Low-severity alert; things are not functioning as they should.
          enum: [ alarm, alert, intrigue ]
      required: [ severity ]
Generation Details

I am using the openapi_generator pub package, which I understand to be a simple wrapper around the java implementation.

Steps to reproduce

The above sample generates the following client code:

Case 1:

  /// Specific Authorized Location
  /// Retrieve data for a single location identified by the &#x60;location_id&#x60; provided,  if the user is authorized to access the location.
  ///
  /// Parameters:
  /// * ...
  ///
  /// Returns a [Future] containing a [Response] with a [LocationData] as data
  /// Throws [DioException] if API call or serialization fails
  Future<Response<LocationData>> getLocation({ ... })

which incorrectly renders as:

Specific Authorized Location Retrieve data for a single location identified by the `location_id` provided, if the user is authorized to access the location.

Case 2:

/// An alert indicating that something is not behaving as expected
///
/// Properties:
/// * [severity] - The severity of the alert.  * `alarm` - Action is urgently required. * `alert` - Actions should be taken to fix the problem. * `intrigue` - Low-severity alert; things are not functioning as they should.
@BuiltValue()
abstract class Alert implements Built<Alert, AlertBuilder> {
    ...
}

(The enum description is correctly displayed in the Swagger UI preview from the IntelliJ OpenAPI Specifications plugin)

Related issues/PRs
Suggest a fix

I believe that the dart generator is stripping newline characters and failing to un-escape symbols like ` and <>.

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

No branches or pull requests

1 participant