0

我正在使用 openapi-generator-maven-plugin 版本 5.4.0 将我的 OpenAPI.json 文件转换为 AsciiDoc。在我的 OpenApi.json 规范中,我为路径参数描述设置了一些格式:

"description": "TestDescription \n Line2 TestDescription",

但是 AsciiDoc 生成器输出它没有格式化:

测试说明第 2 行测试说明

有没有办法保持我的格式?

我如何使用插件:

           <plugin>
              <groupId>org.openapitools</groupId>
              <artifactId>openapi-generator-maven-plugin</artifactId>
              <version>5.4.0</version>
              <executions>
                 <execution>
                    <goals>
                       <goal>generate</goal>
                    </goals>
                    <configuration>
                       <inputSpec>openapi.json</inputSpec>
                       <generatorName>asciidoc</generatorName>
                       <skipValidateSpec>true</skipValidateSpec>
                       <configOptions>
                          <useIntroduction>true</useIntroduction>
                          <useMethodAndPath>true</useMethodAndPath>
                          <useTableTitles>true</useTableTitles>
                       </configOptions>
                       <output>output</output>
                    </configuration>
                 </execution>
              </executions>
           </plugin>

我的 openapi.json 文件:

{
    "openapi": "3.0.1",
    "info": {
        "title": "TestOpenAPI",
        "description": "Testdescription",
        "version": "1.2.3"
    },
    "servers": [
        {
            "url": "http://TestServer"
        }
    ],
    "tags": [
        {
            "name": "testTag",
            "description": "TestDescription"
        }
    ],
    "paths": {
        "/texts": {
            "get": {
                "tags": [
                    "TestTag1"
                ],
                "operationId": "testOperation",
                "parameters": [
                    {
                        "name": "testName",
                        "in": "query",
                        "description": "TestDescription \n Line2 TestDescription",
                        "required": true,
                        "schema": {
                            "pattern": "^(([a-z]{2}_[A-Z]{2})+,){0,9}([a-z]{2}_[A-Z]{2}){1}$",
                            "type": "string",
                            "description": "TestDescription \n Line2 TestDescription"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/test"
                                        },
                                        {
                                            "$ref": "#/components/schemas/test2"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "components": {
            "schemas": {
                "test": {
                    "type": "object",
                    "properties": {
                        "texts": {
                            "type": "array",
                            "xml": {
                                "name": "text"
                            },
                            "items": {
                                "$ref": "#/components/schemas/test"
                            }
                        }
                    },
                    "xml": {
                        "name": "texts"
                    }
                },
                "TextType": {
                    "required": [],
                    "type": "object",
                    "properties": {
                        "key": {
                            "type": "string",
                            "description": "The key of the text"
                        },
                        "value": {
                            "type": "string",
                            "description": "The value of the text"
                        },
                        "category": {
                            "type": "string",
                            "description": "The category of the text"
                        },
                        "language": {
                            "maxLength": 5,
                            "minLength": 5,
                            "pattern": "[a-z]{2}_[A-Z]{2}",
                            "type": "string",
                            "description": "TestDescription \n Line2 TestDescription"
                        }
                    }
                }
            }
        }
    }
}
4

1 回答 1

0

OpenApi 支持 MarkDown 语法来呈现富文本。例如:

description: |
    # Title with *italics*
    Next line
    Some **bold** comments

(在这里查看更多)

现在的问题是:OpenapiTools 插件在遇到此类标记时将如何表现......

于 2022-02-03T17:22:09.447 回答