OpenAPITools / OpenAPITools/openapi-generator

[python-nextgen] Inconsistent enum naming

Open
#15,280 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Python Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

There is a enum naming inconsistence between the python-nextgen generators and others (php, js, ts, go, ruby, java, .net), for example from this enum:

type: string
title: EventType
enum:
  - it.test.company.create
  - it.test.company.update
  - it.test.user.create
  ...

the other generators generate enum keys like CompanyCreate, CompanyUpdate and so on, while the python-nextgen instead generated keys are IT_DOT_COMPANY_DOT_CREATE, IT_DOT_COMPANY_DOT_UPDATE...

It seems like the common part of all the options (in this case it.test) does not get stripped, and special chars get transformed in words instead of removed, it's true that it's more similar to the options I specified in the actual openapi but I think the behaviour of the other generators is way better in the end, other than the fact that it will be better to have consistency across all the generators.

Suggest a fix

What I would expect from the example openapi I put above is an enum with keys COMPANY_CREATE, COMPANY_UPDATE and USER_CREATE.

openapi-generator version

6.5.0

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/14869

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 reviewing the python-nextgen generator and the related pull request #14869, then compare its enum naming with the other generators described in the issue. Reproduce the provided OpenAPI enum example and verify that generated keys omit the shared prefix and represent the expected COMPANY_CREATE, COMPANY_UPDATE, and USER_CREATE names.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.