首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么openapi-generator-maven-plugin忽略我的xml标记名?

为什么openapi-generator-maven-plugin忽略我的xml标记名?
EN

Stack Overflow用户
提问于 2019-10-26 20:14:06
回答 1查看 787关注 0票数 2

我正在使用openapi-generator-maven-plugin

代码语言:javascript
复制
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>4.1.3</version>

使用<withXml>true</withXml>选项。

在我的yaml服务定义文件中描述我的REST操作(XML消息)。我有一个类似这样的模式:

代码语言:javascript
复制
components:
  schemas:
    LoginRequest:
      type: object
      properties:
        customerName:
          type: string
          xml:
            name: customerName
            attribute: false
            wrapped: false
        password:
          type: string
          xml:
            name: hello
            attribute: false
        user:
          type: string
          xml:
            name: user
            attribute: false
            wrapped: false
      title: request
      xml:
        name: request
        attribute: false

和定义的服务:

代码语言:javascript
复制
paths:
  /session/login:
    post:
      tags:
        - sample-controller
      summary: login
      operationId: loginUsingPOST      
      requestBody:
        content:
          application/xml:
            schema:
              $ref: "#/components/schemas/LoginRequest"
        description: request
        required: true
      responses:
        "200":
          description: OK
          content:
            application/xml:
              schema:
                $ref: "#/components/schemas/LoginResponse"

然后我生成客户端代码。但是当我使用它时,发送给http请求的XML使用的是<LoginRequest>而不是<request>

生成器似乎没有考虑到我的-xml信息。

EN

回答 1

Stack Overflow用户

发布于 2019-11-06 00:09:22

例如,您需要将选项放入configOptions

代码语言:javascript
复制
<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <!-- RELEASE_VERSION -->
    <version>4.2.0</version>
    <!-- /RELEASE_VERSION -->
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
                <generatorName>java</generatorName>
                <configOptions>
                   <sourceFolder>src/gen/java/main</sourceFolder>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

参考:https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin#usage

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58570650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档