我正在使用openapi-generator-maven-plugin
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.1.3</version>使用<withXml>true</withXml>选项。
在我的yaml服务定义文件中描述我的REST操作(XML消息)。我有一个类似这样的模式:
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和定义的服务:
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信息。
发布于 2019-11-06 00:09:22
例如,您需要将选项放入configOptions中
<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://stackoverflow.com/questions/58570650
复制相似问题