【问题标题】:Grape Swagger Rails with Markdown带有 Markdown 的 Grape Swagger Rails
【发布时间】:2019-01-21 20:35:12
【问题描述】:

我在 rails 5.2 项目中使用葡萄和 grap-swagger-rails gem。过去,单个 API detail 字符串支持降价。它似乎已被删除。删除它的提交中声明的原因是因为 OAPI 接受 [GFM],但据我所知,这仅在 API 集的整体描述中得到支持,而不是在每个 API 的基础上。

如何使用grape/grape-swagger 或Rails 的其他一些gem 组合基于每个API 获得markdown 或其他漂亮的格式?

【问题讨论】:

    标签: ruby-on-rails swagger


    【解决方案1】:

    原来我错过了一个重要的细节。各个 API 的 detail 字符串已经在使用 GFM 降价!使用heredoc 提供字符串可以得到非常漂亮的细节。

    这是一个人为设计的示例,说明格式良好的 API 可能是什么样子:

     resource :planets do
       desc "Get a list of the planets" do
         detail <<-END
     This is some nicely formatted information with a **bolded** word
     - and
     - some 
     - bullets
     END
       end
       get :planets do
          # ... code to get the planets here
       end
     end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多