Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Go] Golang client code is incorrect with presence of oneOf/allOF #8721

Closed
Etienne-Carriere opened this issue Feb 16, 2021 · 6 comments
Closed

Comments

@Etienne-Carriere
Copy link

Etienne-Carriere commented Feb 16, 2021

Description

We discovered that with presence of oneOf/allOf we have presence of UNKNOWN_BASE_TYPE instead of interface{} (or other know type)

OpenAPI Generator versions

Version tested :

  • 5.0.1
  • master

OpenAPI file

I tested a very simple openAPI v3 file :

openapi: 3.0.1
info:
  description: test
  title: test
  version: 1.5.0
servers:
- url: v1
paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              discriminator:
                propertyName: pet_type
              oneOf:
              - $ref: '#/components/schemas/Cat'
              - $ref: '#/components/schemas/Dog'
      responses:
        "200":
          description: Updated
components:
  schemas:
    Pet:
      discriminator:
        propertyName: pet_type
      properties:
        pet_type:
          type: string
      required:
      - pet_type
      type: object
    Dog:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - $ref: '#/components/schemas/Dog_allOf'
    Cat:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - $ref: '#/components/schemas/Cat_allOf'
    Dog_allOf:
      properties:
        bark:
          type: boolean
        breed:
          enum:
          - Dingo
          - Husky
          - Retriever
          - Shepherd
          type: string
      type: object
    Cat_allOf:
      properties:
        hunts:
          type: boolean
        age:
          type: integer
      type: object

Actual behavior

  • With both go and go-deprecated presence of UNKNOWN_BASE_TYPE which is not a known primitive type in golang

Expected behavior

  • No compilation error
  • At least a interface{} for oneOf
@Etienne-Carriere Etienne-Carriere changed the title [BUG] Golang client code is incorrect with presence of oneOf/allOF [BUG][Go] Golang client code is incorrect with presence of oneOf/allOF Feb 16, 2021
@danaelhe
Copy link

danaelhe commented Mar 3, 2021

I have the same issue with the python client. Has anyone found a work around?

@stevenbrookes
Copy link

I have the same issue with PHP client also. V5.1.1

@vdods
Copy link

vdods commented Jun 7, 2021

I've got the same issue with the rust-server generator -- this happens for me using openapitools/openapi-generator-cli docker image as well as the online generators:

Particular instructions (this one uses the online master branch service):

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"openAPIUrl": "https://github.com/w3c-ccg/vc-http-api/raw/main/docs/verifier.yml"}' 'http://api-latest-master.openapi-generator.tech/api/gen/clients/rust-server' | jq -r '.link' | wget --input-file=- --output-document=verifier.zip
unzip verifier.zip
find rust-server-client -type f -exec grep -Hn UNKNOWN_BASE_TYPE {} \;

The grep command shows the presence of UNKNOWN_BASE_TYPE at various points in the generated code, which therefore doesn't compile.

@vdods
Copy link

vdods commented Jun 7, 2021

Same with using the javascript generator.

@wing328
Copy link
Member

wing328 commented Jun 8, 2022

Should be fixed in v6.0.0. Please give it another try.

@wing328 wing328 closed this as completed Jun 8, 2022
@Etienne-Carriere
Copy link
Author

@wing328 , Thank you very much. I confirm it works well both in request and in response (tested with oneOf). We can close the ticket. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants