yaml - swagger 编辑器中的多行字符串

标签 yaml swagger swagger-ui

如果我将以下规范粘贴到 editor.swagger.io 中:

openapi: 3.0.0
info:
  title: Callback Example
  version: 1.0.0
paths:
  /streams:
    post:
      description: |
        first line
        second line
        third line
      responses:
        '201':
          description: subscription successfully created
          content:
            application/json:
              schema:
                description: subscription information
                required:
                  - subscriptionId
                properties:
                  subscriptionId:
                    description: this unique identifier allows management of the subscription
                    type: string
                    example: 2531329f-fb09-4ef7-887e-84e648214436

描述在一行中呈现:

first line second line third line

即使 yaml 规范声明 block 样式字符串保留换行符:https://yaml-multiline.info/

如何在 swagger 编辑器中使用多行字符串?

最佳答案

您可以使用下面提到的解决方案之一来获得 multiline in swagger。

解决方案一:

description: |
  first line \
  second line \
  third line

enter image description here

解决方案 2:

description: |
  first line <br>
  second line <br>
  third line

enter image description here

关于yaml - swagger 编辑器中的多行字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64085227/

相关文章:

api - 如何正确使用 OpenAPI 使用补丁方法更新资源?

azure - 使用 Azure Active Directory 和 Swagger 进行客户端凭据授权

java - SwaggerUi REST 方法 - 方法生成和使用完全相同的 mime 类型

spring-boot - Swagger 的 @ApiResponses 和 @ApiResponses

XML 到 YAML 转换

C# 解析和更改 yaml 中的字符串

spring-boot - 使用 Open API 进行测试时,带有 HttpEntity 的 Spring Rest Controller API 获取空主体

spring-boot - 如何将 "Example Value"添加到 Swagger 中的参数

css - 标题选择器不响应 Rmarkdown html 报告的 css 中的字体大小规则

python - 将 json 转储到 yaml