poem icon indicating copy to clipboard operation
poem copied to clipboard

[Swagger UI] Markdown codeblocks in description trims indentation

Open DragonDev1906 opened this issue 1 year ago • 0 comments

Expected Behavior

Indentation similar to how it is rendered in markdown, cargo doc, rust analyzer, here on Github

[
  {
    "id": 1,
    "value": {
      "Secret": "Password"
    }
  },
  {
    "id": 2,
    "value": {
      "HashPreimage": "Secret Value"
    }
  }
]

Actual Behavior

Removal of any indentation in code blocks: 2024-02-07-113553_367x260_scrot

I'm not sure if that is a fundamental limitation of swagger or something related to poem-openapi reading the docstring.

Steps to Reproduce the Problem

  1. Create an API with the above shown markdown in the docstring (shown as the description in swagger)
  2. Create a server with let ui = api_service.swagger_ui(); and .nest("/ui", ui)
  3. Go to the swagger UI and look at the documentation of the function created.

Example:

    /// ### Example value
    /// ```
    /// [
    ///   {
    ///     "id": 1,
    ///     "value": {
    ///       "Secret": "Password"
    ///     }
    ///   },
    ///   {
    ///     "id": 2,
    ///     "value": {
    ///       "HashPreimage": "Secret Value"
    ///     }
    ///   }
    /// ]
    /// ```
    #[oai(
        path = "/session/:session_id/keys/:id",
        method = "get",
    )]
    async fn get_key(

Specifications

  • Version: 4.0.0
  • Platform: Linux
  • Subsystem: poem-openapi

DragonDev1906 avatar Feb 07 '24 10:02 DragonDev1906