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/10450 below:

[BUG] [JAVA] oneOf generates incorrect model for primitive types · Issue #10450 · OpenAPITools/openapi-generator · GitHub

Bug Report Checklist Description

Using oneOf will generate a model with incorrect wrong types.

Actual output:
I have three files of models: ClientIp.java, Request,java, Response.java. Request.java has field private ClientIp clientIp = null; with type ClientIp

Expected output:
I have only two files of models: Request,java, Response.java. Request.java has field private String clientIp; with string type

openapi-generator version

openapi-generator-cli 5.2.1
commit : 8403e59
built : 2021-08-16T12:52:51Z
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/

openapi-generator-cli 5.3.0-SNAPSHOT
commit : de95e2a
built : 2021-09-22T15:38:29+04:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/

OpenAPI declaration file content or url
openapi: 3.0.3

info:
  title: java codegen BUG
  description: oneOf generates incorrect model for primitive types
  version: 1.0.0

paths:
  /openapi/example/path:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Request'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'

components:
  schemas:
    ClientIp:
      oneOf:
        - type: string
          format: ipv4
        - type: string
          format: ipv6
      nullable: false
      example: '127.0.0.1' # or '2001:0db8:85a3:0000:0000:8a2e:0370:7334' for IPv6

    Response:
      properties:
        result:
          type: string

    Request:
      properties:
        result:
          type: string
        client_ip:
          $ref: "#/components/schemas/ClientIp"
Generation Details

java -jar openapi-generator-cli.jar generate -g java -i oneOfbug.yaml -o .\gen\

Steps to reproduce

Generate a java client using the above yaml.

Related issues/PRs

it little bit similar to #4130

Suggest a fix

melloware and ojathelonius


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