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
  • #11220
Closed
Open
Issue created Jan 03, 2022 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] DefaultCodeGen doesn't recurse into nested types when looking for imports

Created by: eak24

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?
Description

When specifying schemas that have nested types (for instance, Map<String, Map<String, MyType>>), the MyType custom type doesn't get added to the list of imports and so all the generated clients fail to resolve the MyType symbol in the related API. I noticed this with Python Client, but I believe it would effect others as well.

openapi-generator version

5.3.1

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Test additional properties with ref
  version: '1.0'
servers:
  - url: 'http://localhost:8000/'
paths:
  /ping:
    post:
      operationId: ping
      responses:
        default:
          description: default response
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: object
                  additionalProperties:
                    type: object
                    additionalProperties:
                      "$ref": "#/components/schemas/Person"
components:
  schemas:
    Person:
      type: object
      properties:
        lastName:
          type: string
        firstName:
          type: string

Also here

Generation Details

A simple generation command, like openapi-generator generate -g python will make a Python client that fails during symbol resolution because Person won't be imported in default_api.py.

Steps to reproduce

Assuming pipenv and openapi-generator-cli are both installed and on the path...

openapi-generator-cli generate -g python -i https://gist.githubusercontent.com/ethan92429/07a09ac228dcd2f9ec0b957ddb44148b/raw/074beff13727280dd8119c3547ac36d28e58559b/openApi_generator_issue_11220.yaml &&
pipenv install -r requirements.txt &&
pipenv install -r test-requirements.txt &&
pytest --cov=openapi_client
Related issues/PRs

#10279 (closed)

Suggest a fix

Working on this...

Assignee
Assign to
Time tracking