Почему openapi-generator-maven-plugin игнорирует мои имена тегов xml?

Я использую плагин 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"

И я генерирую клиентский код. Но когда я его использую, XML, отправленный в HTTP-запрос, использует <LoginRequest>, имеет имя тега вместо <request>.

Кажется, что никакая информация из моего -xml не учитывается генератором.


person the duck    schedule 26.10.2019    source источник


Ответы (1)


Вам нужно будет поместить параметр внутри 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://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin#usage

person William Cheng    schedule 05.11.2019