Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8769
Closed
Open
Issue created Feb 19, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][GO] Wrong interface type in generated client model when using oneof

Created by: vikashsparky

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

With certain kind of schema having oneOf with required field, the model generated for client does not have proper syntax for interface

type NFProfile struct {
        interface{} *interface{}
}
openapi-generator version

3.0.0

OpenAPI declaration file content or url
openapi: 3.0.0

info:
  version: '1.1.2'
  title: 'Test Service'
  description: |
    Test Service.

servers:
  - url: '{apiRoot}/nfm/v1'
    variables:
      apiRoot:
        default: https://example.com

paths:
  /instances:
    get:
      summary: Retrieves a collection of Instances
      operationId: GetInstances
      tags:
        - Instances (Store)
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time
          required: false
          schema:
            type: integer
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/3gppHal+json:
              schema:
                type: object
                properties:
                  profile:
                    $ref: '#/components/schemas/NFProfile'
                minProperties: 1

components:
  schemas:
    NFProfile:
      description: Information of an NF Instance discovered by the NRF
      type: object
      required:
        - nfInstanceId
      anyOf:
        - required: [ fqdn ]
        - required: [ ipv4Addresses ]
        - required: [ ipv6Addresses ]
      properties:
        nfInstanceId:
          type: string
        nfInstanceName:
          type: string
        fqdn:
          type: string
        ipv4Addresses:
          type: string
        ipv6Addresses:
          type: string
Generation Details

~/bin/openapitools/openapi-generator-cli generate -g go -o ~/test_dir/ -i test.yaml

Steps to reproduce

~/bin/openapitools/openapi-generator-cli generate -g go -o ~/test_dir/ -i test.yaml

Related issues/PRs
Suggest a fix

Should had generated something like

type NFProfile struct {
        nfProfile *interface{}
}
Assignee
Assign to
Time tracking