question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Etienne-Carrierecommented, Jun 14, 2022

@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 !

1reaction
wing328commented, Jun 8, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found