Skip to content

[BUG] openapi-generators oneOfs are broken #4431

Open
@simllll

Description

@simllll

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I've reported the issue already at the swagger-api, but swithed to this fork recently, unfortantely the issue is not solved here either.

Swagger Definition 2 works! https://test.hokify.com/ats-api/swagger.yaml
Swagger Deifntion 3 / Open API is broken when using "oneOf" with strings and objects. https://test.hokify.com/ats-api/openapi.yaml

running
java -jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i dist/swagger/swagger.yaml -g html2 -o docs

generated a broken html2 output.

If I remove the occurences of "oneOf" and replace them by "type: string" it starts working.

                from:
                    oneOf:
                        -
                            type: string
                        -
                            properties:
                                name:
                                    type: string
                                address:
                                    type: string
                            required:
                                - address
                                - name
                            type: object
                    nullable: true
replyTo:
                    oneOf:
                        -
                            type: string
                        -
                            properties:
                                name:
                                    type: string
                                address:
                                    type: string
                            required:
                                - address
                                - name
                            type: object
                    nullable: true
 type:
                    oneOf:
                        -
                            $ref: '#/components/schemas/UserExtraType'
                        -
                            type: string
openapi-generator version

Building via docker openapitools/openapi-generator-cli:latest (updated 4 hours ago)

OpenAPI declaration file content or url

Swagger Definition 2 works! https://test.hokify.com/ats-api/swagger.yaml
Swagger Deifntion 3 / Open API is broken when using "oneOf" with strings and objects. https://test.hokify.com/ats-api/openapi.yaml

Command line used for generation

I'm geneating the defintions files with tsoa, I also opened an issue at tsoa's github page, and we checked that the issue is definitly not related to tsoa itself. The swagger file is valid, the generator seems to produce broken output here. See also lukeautry/tsoa#474

Steps to reproduce

generate html2 docuematation with the open api defintion file:

java -jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i dist/swagger/swagger.yaml -g html2 -o docs

Related issues/PRs

there are some issues reagrding "oneOf", but none that describes this bug in my opinion.

Suggest a fix

Unfortunatnely no idea how to fix this.. I assume it is something in the underlying library, due to the fact that a lot of output modes are affected (not only html2, also e.g. php client,..).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions