Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Missing XmlSeeAlso annotation #938

Open
neTAC23 opened this issue Aug 4, 2021 · 0 comments
Open

[Java] Missing XmlSeeAlso annotation #938

neTAC23 opened this issue Aug 4, 2021 · 0 comments

Comments

@neTAC23
Copy link

neTAC23 commented Aug 4, 2021

Description

Using maven-codegen-plugin, trying to generate PetDTO.class, with 2 classes inheriting: Cat, Dog.
Java model class after generation:

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2021-08-01T14:29:40.664+03:00[Asia/Jerusalem]")@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true )
@JsonSubTypes({
  @JsonSubTypes.Type(value = DogDTO.class, name = "DogDTO"),
  @JsonSubTypes.Type(value = CatDTO.class, name = "CatDTO"),
})
@XmlRootElement(name = "Pet")
@XmlAccessorType(XmlAccessType.FIELD)
@JacksonXmlRootElement(localName = "Pet")
public class PetDTO implements Serializable{
}
Swagger-codegen version

3.0.29-SNAPSHOT

Swagger declaration file content or url
  schemas:
    Pet:
      type: object
      required:
        - name
        - type
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
          example: doggie
        type:
          type: string
      discriminator:
        propertyName: type
      xml:
        name: Pet
    Dog:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            bark:
              type: boolean
      x-discriminator-value: DogDTO
    Cat:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            age:
              type: integer
      x-discriminator-value: CatDTO
Command line used for generation

Using swagger-maven-plugin:

	<plugin>
                <groupId>io.swagger.codegen.v3</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>3.0.28-SNAPSHOT</version>
                <executions>
                    <execution>
                        <id>petStoreRestClient</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/petstore.yaml</inputSpec>
                            <language>java</language>
                            <generateModels>true</generateModels>
                            <modelPackage>com.swagger.test.petstore.dto</modelPackage>
                            <modelNameSuffix>DTO</modelNameSuffix>
                            <withXml>true</withXml>
                            <configOptions>
                                <library>resttemplate</library>
                                <sourceFolder>src/gen/java/main</sourceFolder>
                                <serializationLibrary>jackson</serializationLibrary>
                                <dateLibrary>java8</dateLibrary>
                                <java8>true</java8>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Suggest a fix/enhancement

I have submitted the following PR for this issue: #937

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant