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
  • #1302
Closed
Open
Issue created Oct 23, 2018 by Administrator@rootContributor

[Python] Support for package hierarchy

Created by: mmunz-nextdoor

Description

I am trying to generate a service client for a project that uses a particular package hierarchy by convention. I have tried the following but am yet to generate a client that I can successfully import, due to mis-matching/incorrect import statements, and files that are placed in the wrong folders.

For example #1 (below) I get code like import api where import foo.bar.baz.api is desired. With example #2, I get directories like foo.bar.baz.my_client.model when foo/bar/baz/my_client/model is desired.

ex.1)

openapi-generator generate -g python -l python -c my_config.json \
    --api-package api --model-package model \
    --http-user-agent 'my_agent' \
    --log-to-stderr \
    -i ./api/my_spec.yaml -o $CLIENT_DIR

ex.2)

openapi-generator generate -g python -l python -c my_config.json \
    --api-package foo.bar.baz.my_client.api --model-package foo.bar.baz.my_client.model \
    --http-user-agent 'my_agent' \
    --log-to-stderr \
    -i ./api/my_spec.yaml -o $CLIENT_DIR

my_config.json:

  "packageName":"foo.bar.baz.my_client",
  "projectName":"my_project",
  "packageVersion": "1.0.0",
  "sortParamsByRequiredFlag": "true",
  "hideGenerationTimestamp": "true",
  "generateSourceCodeOnly": "false",
  "library": "urllib3"
}
openapi-generator version

3.3.1

OpenAPI declaration file content or url

I don't believe this is relevant. If needed I can provide a version of the spec.

Command line used for generation

See above.

Steps to reproduce

Run either of the commands above.

Related issues/PRs

I didn't find any.

Suggest a fix/enhancement

It seems like there is some code that is parsing the "foo.bar.baz" syntax into a file path since some of the files are correctly placed with the right import statements. Presumably some of the generator code (the part that handles --api-package api --model-package model) is not correctly handling these package names.

Thanks for reviewing this. Any pointers/suggestions would be really appreciated!

Assignee
Assign to
Time tracking