swagger-api / swagger-api/swagger-codegen

[General] refactor the type-mapping logic to clearly separate build-in types from API-defined types

Open
#5,027 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

Swagger Codegen has some logic which selects type names for generated models and for properties.
This handles both mapping to build-in types of the programming language (e.g. for Java int/double/String/BigDecimal/UUID/...) and name conversion (e.g. case change, escaping for reserved words, model name prefix/suffix) for types defined in the API definition file (mainly object and enum types).

Currently the code is a bit convoluted, which leads to bugs like #3678 (where the suffix/prefix is applied to a build-in type).

Solution proposal

This logic needs to be refactored to separate both functions clearly. Any name modifications should only be applied to for API defined types, not to build-in types of the programming language.
(I guess handling of maps/lists would also be part of this.)

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

The issue names no files or tests, so start by locating the type-mapping logic used for generated models and properties, then review bug #3678 for the prefix/suffix failure. Trace built-in, API-defined, map, and list handling; done means name modifications apply only to API-defined types and relevant generation tests pass.

Written by the indexing model from the issue text.

Assessment

Domain
devtools
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.