OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.3k stars 6.45k forks source link

[BUG] openapi-generators oneOfs are broken #4431

Open simllll opened 4 years ago

simllll commented 4 years ago

Bug Report Checklist

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.

1.

                from:
                    oneOf:
                        -
                            type: string
                        -
                            properties:
                                name:
                                    type: string
                                address:
                                    type: string
                            required:
                                - address
                                - name
                            type: object
                    nullable: true
  1. replyTo:
                    oneOf:
                        -
                            type: string
                        -
                            properties:
                                name:
                                    type: string
                                address:
                                    type: string
                            required:
                                - address
                                - name
                            type: object
                    nullable: true
  2. 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 https://github.com/lukeautry/tsoa/issues/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,..).

auto-labeler[bot] commented 4 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.