Skip to content

[BUG] Oneof under #/components/schemas/ generates invalid code for OAS 3.0 #9791

@haisum

Description

@haisum

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

oneOf block in this spec produces undefined model OneOfarraystring. I have tried and reproduced this with Java and Go generators and looks like this behavior is consistent for all the generators.

OpenAPI declaration file content or url
{
  "openapi": "3.0.0",
  "info": {
    "title": "",
    "version": "v2"
  },
  "servers": [
    {
      "url": ""
    }
  ],
  "externalDocs": {
    "description": "",
    "x-amf-title": "About",
    "url": ""
  },
  "paths": {
    "/database/databases": {
      "get": {
        "description": "List databases.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/database_databases_query"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/database_databases"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "database_databases": {
        "description": ".",
        "type": "array",
        "items": {}
      },
      "database_databases_query": {
        "description": ".",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "uuid": {
            "description": "Database uuid filter",
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "string"
              }
            ]
          },
          "status": {
            "description": "Database status filter",
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "enum": [
                    "CREATE_IN_PROGRESS",
                    "CREATED",
                    "UPDATE_IN_PROGRESS",
                    "DELETE_IN_PROGRESS",
                    "DELETED"
                  ],
                  "type": "string"
                }
              },
              {
                "enum": [
                  "CREATE_IN_PROGRESS",
                  "CREATED",
                  "UPDATE_IN_PROGRESS",
                  "DELETE_IN_PROGRESS",
                  "DELETED"
                ]
              }
            ]
          }
        }
      }
    }
  }
}
Generation Details
openapi-generator-cli   generate -i api-oas3-modified.json -g go-server -o  generated-sdk/go-server --enable-post-process-file
openapi-generator-cli   generate -i api-oas3-modified.json -g go -o  generated-sdk/go --enable-post-process-file
openapi-generator-cli   generate -i api-oas3-modified.json -g java -o  generated-sdk/java --enable-post-process-file
Steps to reproduce
  1. Put spec in a file
  2. Run generation cli commands above
  3. Search for OneOfarraystring in DatabaseDatabasesQuery model in generated code
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