Repository navigation
Closed
Milestone
Description
Is there a way to generate the model java classes that do not contain the fields and getters/setters for the base class?
For example:
swagger file model:
definitions:
TractPage:
type: object
x-swagger-router-model: com.gotransverse.tract.api.billing.dto.TractPage
#x-swagger-router-model: TractPage
required:
- page_num
- page_size
properties:
page_num:
description: The page number of this page of the collection
type: integer
format: int32
example: 1
page_size:
description: The page size of this page of the collection
type: integer
format: int32
example: 50
num_elements:
description: The number of elements in this page of the collection
type: integer
format: int32
example: 1
total_num:
description: The total number of elements in the complete collection
type: integer
format: int32
example: 100
links:
description: The list of HATEOAS links for the page
type: array
items:
$ref: '#/definitions/Link'
PersonsPage:
description: A page for person
x-swagger-router-model: com.gotransverse.tract.api.billing.dto.PersonsPage
#x-swagger-router-model: PersonsPage
allOf:
- $ref: '#/definitions/TractPage'
- type: object
required:
- people
properties:
people:
description: The list of people in this page
type: array
items:
$ref: '#/definitions/Person'The Java classes that get generated look like:
public class Page {
private Integer pageNum = null;
private Integer pageSize = null;
private Integer numElements = null;
private Integer totalNum = null;
private List<Link> links = new ArrayList<Link>();
...
}
public class PersonsPage extends Page {
private Integer pageNum = null;
private List<Link> links = new ArrayList<Link>();
private Integer numElements = null;
private List<Person> people = new ArrayList<Person>();
private Integer pageSize = null;
private Integer totalNum = null;
...
}
The PersonsPage class should not have the fields that are contained in the Page class - at least in the default case.
Is this by design? Or is this a defect?
Activity
nickcmaynard commentedon Jan 27, 2016
+1. This used to work without duplicating fields. Problem seems to have been introduced with the refactor of the JaxRS server codegen.
nickcmaynard commentedon Jan 31, 2016
And, of course, causes some unpredictable problems as you'd expect when properties are overriden in Java subclasses. This can cause potentially serious bugs.
nickcmaynard commentedon Jan 31, 2016
See PR #1120, #1094.
wing328 commentedon Jul 19, 2016
@cbornet PR (#3393) has been merged into master. Please pull the latest to give it a try.