swagger-api / swagger-api/swagger-codegen

[Python] Incorrect handling of model-name-prefix and model-name-suffix

Open
#7,865 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When the --model-name-prefix or --model-name-suffix are used, the model filename
includes the prefix/suffix, but the import filename includes them twice.

For example, if we use "--model-name-prefix swg" and the model is "pet", the resulting
model filename is "swg_pet.py", but corresponding import is:

from swagger_server.models.swg_swg_pet import SwgPet

Also, reserved word escaping should be done after the prefix/suffix has been added.

Swagger-codegen version

ref: refs/heads/master

Swagger declaration file content or url
Command line used for generation
Steps to reproduce

java -jar swagger-codegen-cli.jar generate -l python-flask --model-name-prefix swg

Related issues/PRs
Suggest a fix/enhancement

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided java -jar swagger-codegen-cli.jar generate -l python-flask --model-name-prefix swg command and inspect the Python Flask model naming and import-generation entry points. Done means prefixed or suffixed model filenames are referenced exactly once, and reserved-word escaping occurs after the prefix or suffix is added.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.