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

Swagger Code Generator -3.0.11 for @type discriminator

Open
#498 2 comments 1 reaction 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

In Swagger Code Generator 3.0.11, model generation is corrected to handle the variables that start with '@' symbol .

But if same variable is used as discriminator in OPEN API 3.0.0, resultant model object looks like below -
@JsonTypeId
private ResourceTypeEnumType _atType = null;

but the expectation is
@JsonTypeId
@JsonProperty("@type")
private ResourceTypeEnumType _atType = null;

Problem : During serialization, json string does not contain @type attribute. If the model object is corrected to include @JsonProperty, then serialized json string contains @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

No source file or test is named. Start by reproducing Swagger Code Generator 3.0.11 output for an OpenAPI 3.0.0 model whose discriminator is "@type", then trace the Java model-generation template or entry point that emits the discriminator field. Done means the generated field includes @JsonProperty("@type") and serialization contains the @type attribute.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.