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
  • #8860
Closed
Open
Issue created Feb 28, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] Generator try to use oneOf* model but does not create it

Created by: Adi1231234

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

On oneOf usage in openAPI declaration the generator try to use oneOf* model but does not create it in any language

openapi-generator version

5.0.1

OpenAPI declaration file content or url
{
  "openapi": "3.0.0",
  "info": {
    "title": "service",
    "description": "API",
    "version": "1.0",
    "contact": {}
  },
  "tags": [],
  "servers": [],
  "components": {
    "schemas": {
      "Category": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "parentCategoryId": { "type": "number" }
        },
        "required": ["name", "parentCategoryId"]
      },
      "GetManyCategoryResponseDto": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/Category" }
          },
          "count": { "type": "number" },
          "total": { "type": "number" },
          "page": { "type": "number" },
          "pageCount": { "type": "number" }
        },
        "required": ["data", "count", "total", "page", "pageCount"]
      }
    }
  },
  "paths": {
    "/categories": {
      "get": {
        "operationId": "getManyBaseCategoriesControllerCategory",
        "summary": "Retrieve many Category",
        "parameters": [
          {
            "name": "fields",
            "description": "Selects resource fields",
            "required": false,
            "in": "query",
            "schema": { "type": "array", "items": { "type": "string" } },
            "style": "form",
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "Get many base response",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/GetManyCategoryResponseDto"
                    },
                    {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Category" }
                    }
                  ]
                }
              }
            }
          }
        },
        "tags": ["Categories"]
      }
    }
  }
}
Generation Details
Steps to reproduce

execute - java -jar openapi-generator-cli.jar generate -i categories.swagger -o out -g (any language)

then at api/categories_api the generated function is:

Future<Response<OneOfGetManyCategoryResponseDtoarray>> getManyBaseCategoriesControllerCategory({ 
  BuiltList<String> fields,
})

the problem is that OneOfGetManyCategoryResponseDtoarray class does not exist in any file.

Related issues/PRs

#3965 - Similar a bit

Suggest a fix
Assignee
Assign to
Time tracking