Skip to content

[BUG][Python] "sub-module" definition in packageName does not work #1658

@tomghyselinck

Description

@tomghyselinck
Description

We define "packageName": "myapi.rest.client" in the config file for the python generator.
This is because we want our REST API to de a submodule of the myapi.

The generated code does not give us the expected code layout.

openapi-generator version

I used OpenAPI generator CLI version 4.0.0-SNAPSHOT:
https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/openapi-generator-cli-4.0.0-20181210.103357-85.jar

OpenAPI declaration file content or url

python-sub-module.yaml:

openapi: '3.0.1'
info:
        title: Test REST API
        version: "1.0"
servers:
- url: /
paths:
        /data:
                get:
                        summary: Get the Remote Data
                        responses:
                                '200':
                                        description: Remote Object
                                        content:
                                                application/json:
                                                        schema:
                                                                properties:
                                                                        data:
                                                                                type: string
Command line used for generation
java -jar openapi-generator-cli-4.x.jar generate -i ./python-sub-module.yaml -g python -o ./client/python/ -c ./config/python.json
Steps to reproduce

python-sub-module.sh:

#!/bin/sh
mkdir -p config
cat >config/python.json <<-CONFIG
{
        "packageName": "myapi.rest.client",
        "projectName": "myapi-rest-client"
}
CONFIG

rm -rf client/python/
java -jar openapi-generator-cli-4.x.jar generate -i ./python-sub-module.yaml -g python -o ./client/python/ -c ./config/python.json
tom@localhost:~/issues$ ./python-sub-module.sh
tom@localhost:~/issues$ tree -aAC client/python/
client/python/
├── docs
│   └── DefaultApi.md
├── .gitignore
├── git_push.sh
├── myapi
│   └── rest
│       └── client
│           └── api
│               └── default_api.py
├── myapi.rest.client
│   ├── api
│   │   └── __init__.py
│   ├── api_client.py
│   ├── configuration.py
│   ├── __init__.py
│   ├── models
│   │   └── __init__.py
│   └── rest.py
├── .openapi-generator
│   └── VERSION
├── .openapi-generator-ignore
├── README.md
├── requirements.txt
├── setup.py
├── test
│   ├── __init__.py
│   └── test_default_api.py
├── test-requirements.txt
├── tox.ini
└── .travis.yml

10 directories, 20 files
Related issues/PRs
Suggest a fix

Fixes in progress:

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