swagger-api / swagger-api/swagger-codegen

@JsonSubTypes are not generated for jaxrs-resteasy

Open
#12,075 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

Description

I am trying to generate code using jaxrs-resteasy for my swagger file as follows,

<artifactId>swagger-codegen-maven-plugin</artifactId>
<executions>
    <execution>
        <configuration>
            <language>jaxrs-resteasy</language>
        </configuration>
    </execution>
</executions>

Generated code does NOT generate following expected @JsonSubTypes annotations.

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "businessPartnerType", visible = true )
@JsonSubTypes({
  @JsonSubTypes.Type(value = BusinessPartnerCompany.class, name = "BusinessPartnerCompany"),
  @JsonSubTypes.Type(value = BusinessPartnerPerson.class, name = "BusinessPartnerPerson"),
})
public class BusinessPartner {

But, I noticed there are generated correctly when I use,

<artifactId>swagger-codegen-maven-plugin</artifactId>
<executions>
    <execution>
        <configuration>
            <language>java</language>
            <additionalProperties>
                <additionalProperty>library=resteasy</additionalProperty>
            </additionalProperties>
        </configuration>            
    </execution>
<executions>
Swagger-codegen version

I am using following dependency in my pom.xml file

<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.36</version>

I guess I am missing some configurations for jaxrs-resteasy, can someone help me on 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

Start by reproducing the two Maven plugin configurations in pom.xml: jaxrs-resteasy and java with the resteasy library. Compare the generated model output and trace where the @JsonTypeInfo and @JsonSubTypes annotations are selected; done means jaxrs-resteasy generates the expected annotations as the java/resteasy configuration does.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.