Open
Description
Description
If there are two models in the swagger definition whose subproperties are the same, the code generator always uses the first one.
e.g. take the following two definitions
house:
type: object
properties:
has_walls:
type: boolean
attributes:
type: object
properties:
name:
type: string
person:
type: object
properties:
has_legs:
type: boolean
attributes:
type: object
properties:
name:
type: string
Swagger doesnt generate a PersonAttributes class at all, and instead generates:
public class Person {
@JsonProperty("has_legs")
private Boolean hasLegs = null;
@JsonProperty("attributes")
private HouseAttributes attributes = null;
Swagger-codegen version
Latest snapshot 2.2.2
Swagger declaration file content or url
swagger: '2.0'
info:
version: 0.0.0
title: Simple API
paths:
/:
get:
responses:
200:
description: OK
schema:
$ref: "#/definitions/house"
400:
description: OK
schema:
$ref: "#/definitions/person"
definitions:
house:
type: object
properties:
has_walls:
type: boolean
attributes:
type: object
properties:
name:
type: string
person:
type: object
properties:
has_legs:
type: boolean
attributes:
type: object
properties:
name:
type: string
Command line used for generation
java -jar bin/swagger-codegen-cli.jar generate -v -i ./swagger.yaml -l spring -Dmodels -o .
Steps to reproduce
Copy the above swagger.yaml into http://editor.swagger.io/#!/ or use the latest CLI to build as above.