Skip to content

[BUG] OneOf not working with null #19258

@devhl-labs

Description

@devhl-labs

Generating this client results in bad output. The type is showing as OneOf when it should be ApplicationTypes.

image

generatorName: csharp
library: generichost
outputDir: 'C:\Users\devhl\repos\openapi-generator-sample-output\Discord\generated'
inputSpec: 'https://raw.githubusercontent.com/discord/discord-api-spec/main/specs/openapi.json'
additionalProperties:
  modelPropertySorting: default
  operationParameterSorting: default

The model looks like this

      "BasicApplicationResponse": {
        "type": "object",
        "properties": {
          ...
          "type": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ApplicationTypes"
              }
            ]
          },

It looks like the issue starts in the DefaultCodegen, but I don't see an easy way to fix it.
image

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
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions