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.48k stars 6.5k forks source link

[BUG][go] When oneOf is present in the object object properties are ignored. #14250

Open wtrocki opened 1 year ago

wtrocki commented 1 year ago

Bug Report Checklist

Description

When oneOf is present on the object the other properities aren't included in that object.

openapi-generator version

6.2.1

OpenAPI declaration file content or url
    RegionConfig:
      type: object
      discriminator:
        mapping:
          AWS: '#/components/schemas/AWSRegionConfigView'
          AZURE: '#/components/schemas/AzureRegionConfigView'
        propertyName: providerName
      oneOf:
      - $ref: '#/components/schemas/RegionConfigView'
      properties:
        test:
          type: integer
          format: int32

test property would not be included into object.

Steps to reproduce
Related issues/PRs
Suggest a fix
wtrocki commented 1 year ago

I'm going to work on this issue. There is little details but I have the context so solve it. Normally there should be an {ModelName}AllOf object introduced that will contain parent fields but somehow it is not happening.

chivalryq commented 1 year ago

Any update on this issue? I met the same error. @wtrocki I'd like to help if there are some details provided.

wtrocki commented 1 year ago

@chivalryq you would need to edit your schema - move properties from parent to each element in oneOf. As for fix in openapi generator we need this PR merged: https://github.com/OpenAPITools/openapi-generator/pull/14459

chivalryq commented 1 year ago

@wtrocki Thanks for your reply. Do you mean that I can either edit the schema or wait for new version that contains support on OneOf? Or I have to both do the two things?

UPDATE: I see the result of only changing the schema is acceptable. Thanks!

wtrocki commented 1 year ago

I see the result of only changing the schema is acceptable. Thanks!

Glad it works for you