OpenAPITools / OpenAPITools/openapi-generator

[BUG][golang] NullableInt32 and AnyOfstringstring are not generated for golang

Open
#11,291 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

hi

I have this yaml file.

openapi: 3.0.0

info:
  version: '1.0.0'
  title: 'Types'

paths: {}
components:
  schemas:

    AdditionalQosFlowInfo:
      anyOf:
        - anyOf:
            - type: string
              enum:
                - MORE_LIKELY
            - type: string
        - $ref: '#/components/schemas/NullValue'

    Arp:
      type: object
      properties:
        priorityLevel:
          $ref: '#/components/schemas/ArpPriorityLevel'
      required:
        - priorityLevel

    ArpPriorityLevel:
      type: integer
      nullable: true

    NullValue:
      enum:
        - null

there is a nullable type in it and an anyof/anyof type.

When I genarte go models for this, the generator does not generate NullableInt32 and AnyOfstringstring models, but there are some reference in the generated models, which are using those

E.g.

type Arp struct {
	// nullable true shall not be used for this attribute
	PriorityLevel NullableInt32 `json:"priorityLevel"`
}

type AdditionalQosFlowInfo struct {
	AnyOfstringstring *AnyOfstringstring
	NullValue *NullValue
}

But there is no model for this NullableInt32 and for AnyOfstringstring, so it shows an error....

Can you tell me what I am doing wrong? Why this is not generated? Or am I misunderstand something?
thanks
Akos

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI 3 YAML and the Go model-generation entry point; inspect how nullable integer and nested anyOf schemas are discovered versus referenced. Compare the generated Arp and AdditionalQosFlowInfo declarations with the missing NullableInt32 and AnyOfstringstring definitions, then confirm the corrected output compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.