swagger-api / swagger-api/swagger-codegen-generators

[ALL] Return value of `getSchemaType()` is unclear/inconsistent

Open
#317 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

The interpretation of the return value of DefaultCodegenConfig.getSchemaType() is unclear.

Both the implementation of the method and its documentation suggest that this method should return Swagger types (e.g. integer, file, ...).

However, at least some usages suggest that it should return language types (e.g. int, File, ...).

So far, I've identified two places which such problems:

Problem 1: addImport()

In fromProperty() the field baseType is set like this:

codegenProperty.baseType = getSchemaType(propertySchema);

And then later in addVars() that baseType is used to add an import:

addImport(codegenModel, cp.baseType);

However, addImport() seems to expect a language type, not a swagger type.

Problem 2: toInstantiationType()

In toInstantiationType() the method is used like this:

String inner = getSchemaType(additionalProperties);
return instantiationTypes.get("map") + "<String, " + inner + ">";

This code clearly expects a language type (or Java-like type) - not a Swagger type.

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 with DefaultCodegenConfig.getSchemaType() and its documentation, then trace the usages named in fromProperty(), addVars(), addImport(), and toInstantiationType(). Determine whether the method's contract is Swagger types or language types, and document or align those usages consistently; done means the contract and affected call sites no longer conflict.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.