swagger-api / swagger-api/swagger-codegen

java generation fails to generate proper constructors

Open
#7,756 2 comments 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

I'm using the geojson swagger file
https://gist.github.com/bubbobne/fe5f2db65acf039be6a9fd92fc9c7233

to generate code for Point and Polygon. Overall it works fine, however it fails to generate the "type" which should be "point" for Point and "polygon" for Polygon.

Swagger-codegen version

swagger-codegen-maven-plugin 2.2.3

Swagger declaration file content or url

look at Polygon or Point in the geojson swagger above.

Command line used for generation

I use Maven

generate-geojson generate src/main/resources/geometry_geojson.yaml java java8 src/java/main
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

The hack is basically I add a constructor to the class like so:

public Point() {
setType(TypeEnum.POINT);
}

or for Polygon:

public Polygon() {
setType(TypeEnum.POLYGON);
}

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 Java generation with the linked GeoJSON Swagger file, swagger-codegen-maven-plugin 2.2.3, and the shown Maven configuration. Inspect the generated Point and Polygon classes and the handling of their type fields and enum values. Done means generation produces constructors that initialize Point to point and Polygon to polygon without manual edits.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.