swagger-api / swagger-api/swagger-codegen

[swagger-codegen Java] codegen generates invalid Java classes for descriptions of simple type integer or string

Open
#2,314 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Issue: Bug Swagger-Parser
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

The following description section inside an OAI specification in yaml led to invalid java classes HelloWorldResponse.java and UsageLimit.java after code generation in version 2.1.5

definitions:
  HelloWorldResponse:
    type: string
  UsageLimit:
    type: integer
    description: Defines the usage limit
  ErrorResponse:
    required:
      - message
    properties:
      message:
        type: string

see GIST [https://gist.github.com/h2m/322effb99d5261671ca1]

Is this a bug, an invalid specification or a problem with Java not being able to subclass a String or Integer 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 by reviewing the YAML example and linked Gist, then inspect the generated HelloWorldResponse.java and UsageLimit.java from swagger-codegen 2.1.5. Determine whether the specification is valid and why code generation produces invalid Java classes; done means the cause is established and the issue has a clear resolution.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.