Repository navigation
Closed
Milestone
Description
Description
When a parent definition contains an array of enums the generated models don't compile.
Swagger-codegen version
Latest version from master.
Swagger declaration file content or url
swagger: '2.0'
info:
description: 'My Service'
version: 1.0.0
title: My Service
schemes:
- http
paths:
/templates:
get:
summary: Returns all
description: ''
operationId: getAll
produces:
- application/json
responses:
'200':
description: successful operation
schema:
type: array
items:
$ref: '#/definitions/Parent'
definitions:
Parent:
discriminator: id
properties:
id:
type: string
status:
type: array
items:
type: string
enum:
- active
- inactive
- pending
required:
- id
Child:
allOf:
- $ref: "#/definitions/Parent"
- type: object
properties:
subProperty:
type: stringCommand line used for generation
java -Dmodels -Dapis -DsupportingFiles=pom.xml,README.md,build.gradle,settings.gradle,gradle.properties,AndroidManifest.xml -jar /home/third-parties/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l java -o java
Steps to reproduce
Generate the model.
Compile with gradle compileJava.
Here is the compilation error I get.
Child.java:65: error: name clash: status(List<Child.StatusEnum>) in Child and status(List<Parent.StatusEnum>) in Parent have the same erasure, yet neither overrides the other
public Child status(List<StatusEnum> status) {
^
Child.java:72: error: getStatus() in Child cannot override getStatus() in Parent
public List<StatusEnum> getStatus() {
^
return type List<Child.StatusEnum> is not compatible with List<Parent.StatusEnum>
Child.java:75: error: name clash: setStatus(List<Child.StatusEnum>) in Child and setStatus(List<Parent.StatusEnum>) in Parent have the same erasure, yet neither overrides the other
public void setStatus(List<StatusEnum> status) {
^
3 errors
:compileJava FAILED
Suggest a Fix
IMHO subclasses should not redefine inherited properties, getters and setters.
Activity
wing328 commentedon Jul 19, 2016
@cbornet PR (#3393) has been merged into master. Please pull the latest to give it a try.