A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/OpenAPITools/openapi-generator/issues/9981 below:

[BUG] [Spring] OneOf base class not generated · Issue #9981 · OpenAPITools/openapi-generator · GitHub

Bug Report Checklist Description

While generating a Java server code with polymorphism (oneOf), we get a compilation error while the base class is imported due to it was not generated.

openapi-generator version

5.2.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: OneOf example
  version: '1.0.0'
paths:
  '/vegetables':
    get:
      summary: Get vegetables
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/Tomato'
                - $ref: '#/components/schemas/Carrot'
        '404':
          description: Not Found
      operationId: getVegetables
components:
  schemas:
    Tomato:
      type: object
      properties:
        property1:
          type: integer
        property2:
          type: string
    Carrot:
      type: object
      properties:
        property3:
          type: integer
        property4:
          type: string  

Plugin configuration:

<plugin>
	<version>5.2.0</version>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>generate-rest-api</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <inputSpec>${project.basedir}/src/main/resources/openapi-rest.yml</inputSpec>
                <generatorName>spring</generatorName>
                <generateSupportingFiles>true</generateSupportingFiles>                
                <configOptions>
                    <dateLibrary>java8</dateLibrary>
                    <java8>true</java8>
                    <interfaceOnly>true</interfaceOnly>
                    <apiPackage>com.example</apiPackage>                    
                    <modelPackage>com.example.dto</modelPackage>
                    <sourceFolder>src/gen/java/main</sourceFolder>                    
                </configOptions>
            </configuration>
        </execution>       
    </executions>    
</plugin>
Generation Details Steps to reproduce

Generate code with openapi-generator-maven-plugin.

Related issues/PRs Suggest a fix

Following the provided example, a OneOfTomatoCarrot class must be generated.

MikhailovNikita, kondei, redamessoudi and LeComptoirDesPharmacies


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4