Skip to content

Swagger php client duplicated models generated #3430

@alexandruserban

Description

@alexandruserban
Description

When I run the command swagger-codegen-cli for PHP I get duplicated models like:
Body, Body1 and LicensesFeatures and LicensesFeatures1. The only difference between the models as I can see is that on the setter methods one model throws and exception if the $value is empty as the other does not check if the $value is empty and does not throw an exception.

Swagger-codegen version

Version 2.2.0

Swagger declaration file content or url

{"swagger":"2.0","info":{"version":"0.0.1","title":"Platform license api","description":"Api to retrieve license information for MyFirm instances"},"host":"host.local","basePath":"/api/v1","schemes":["http","https"],"consumes":["application/vnd.api+json"],"produces":["application/vnd.api+json"],"tags":[{"name":"license","description":"License management api endpoints"}],"paths":{"/licenses":{"x-swagger-router-controller":"licenses","get":{"tags":["license"],"summary":"Find a license by its instance name","description":"Gets the license for an instance","operationId":"getLicenses","responses":{"200":{"description":"List of licenses","schema":{"type":"array","items":{"type":"object","required":["instance","startDate","endDate","users","spaces","features"],"properties":{"instance":{"type":"string"},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"users":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"}}},"spaces":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"}}},"diskstorage":{"type":"integer","format":"int32"},"features":{"type":"array","items":{"type":"object","required":["name","key"],"properties":{"name":{"type":"string"},"key":{"type":"string"},"disabled":{"type":"boolean"}}}},"disabled":{"type":"boolean"}}}}}}},"post":{"tags":["license"],"summary":"Creates a new license for an instance","description":"Creates a new license for an instance","operationId":"createLicense","parameters":[{"name":"body","in":"body","description":"License object to be saved","required":true,"schema":{"type":"object","required":["instance","startDate","endDate","users","spaces","diskstorage","features"],"properties":{"instance":{"type":"string","minLength":0},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"users":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"}}},"spaces":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"}}},"diskstorage":{"type":"integer","format":"int32"},"features":{"type":"array","items":{"type":"object","required":["name","key"],"properties":{"name":{"type":"string","minLength":0},"key":{"type":"string","minLength":0},"disabled":{"type":"boolean"}}}},"disabled":{"type":"boolean"}}}}],"responses":{"201":{"description":"Responds with the saved license data","schema":{"type":"object","required":["instance","startDate","endDate","users","spaces","features"],"properties":{"instance":{"type":"string"},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"users":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"}}},"spaces":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"}}},"diskstorage":{"type":"integer","format":"int32"},"features":{"type":"array","items":{"type":"object","required":["name","key"],"properties":{"name":{"type":"string"},"key":{"type":"string"},"disabled":{"type":"boolean"}}}},"disabled":{"type":"boolean"}}}},"400":{"description":"Invalid request","schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}},"409":{"description":"A license with the same unique properties already exists"}}}},"/licenses/{instance}":{"x-swagger-router-controller":"licenses","get":{"tags":["license"],"summary":"Find a license by its instance name","description":"Gets the license for an instance","operationId":"getLicense","parameters":[{"name":"instance","in":"path","description":"The id of the instance","required":true,"type":"string"}],"responses":{"200":{"description":"License for an instance","schema":{"type":"object","required":["instance","startDate","endDate","users","spaces","features"],"properties":{"instance":{"type":"string"},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"users":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"}}},"spaces":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"}}},"diskstorage":{"type":"integer","format":"int32"},"features":{"type":"array","items":{"type":"object","required":["name","key"],"properties":{"name":{"type":"string"},"key":{"type":"string"},"disabled":{"type":"boolean"}}}},"disabled":{"type":"boolean"}}}},"404":{"description":"License not found","schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}}},"put":{"tags":["license"],"summary":"Updates the license properties and relationships for an instance","description":"Updates the license properties and relationships for an instance","operationId":"updateLicense","parameters":[{"name":"instance","in":"path","description":"The id of the instance","required":true,"type":"string"},{"name":"body","in":"body","description":"License object with properties and relationships to update","required":true,"schema":{"type":"object","properties":{"instance":{"type":"string","minLength":0},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"users":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"}}},"spaces":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"}}},"diskstorage":{"type":"integer","format":"int32"},"features":{"type":"array","items":{"type":"object","required":["name","key"],"properties":{"name":{"type":"string","minLength":0},"key":{"type":"string","minLength":0},"disabled":{"type":"boolean"}}}},"disabled":{"type":"boolean"}}}}],"responses":{"200":{"description":"Responds with the saved license data","schema":{"type":"object","required":["instance","startDate","endDate","users","spaces","features"],"properties":{"instance":{"type":"string"},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"users":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"}}},"spaces":{"type":"object","properties":{"total":{"type":"integer","format":"int32"},"external":{"type":"integer","format":"int32"},"internal":{"type":"integer","format":"int32"}}},"diskstorage":{"type":"integer","format":"int32"},"features":{"type":"array","items":{"type":"object","required":["name","key"],"properties":{"name":{"type":"string"},"key":{"type":"string"},"disabled":{"type":"boolean"}}}},"disabled":{"type":"boolean"}}}},"404":{"description":"License not found","schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}}},"delete":{"tags":["license"],"summary":"Removes a license file for an instance an instance","description":"Removes the license for an instance","operationId":"removeLicense","parameters":[{"name":"instance","in":"path","description":"The id of the instance","required":true,"type":"string"}],"responses":{"200":{"description":"True if successfull","schema":{"type":"boolean"}},"404":{"description":"License not found","schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}}}},"/licenses/{instance}/feature/{feature}/validate":{"x-swagger-router-controller":"licenses/feature","post":{"tags":["license"],"summary":"Validates if a feature license is valid","description":"Validates if a feature license is valid","operationId":"validateLicense","parameters":[{"name":"instance","in":"path","description":"The id of the instance","required":true,"type":"string"},{"name":"feature","in":"path","description":"feature name","required":true,"type":"string"},{"name":"body","in":"body","description":"The licensekey of a certain feature","required":true,"schema":{"type":"string","minLength":0}}],"responses":{"200":{"description":"Is a valid license key 'true' or 'false'","schema":{"type":"boolean"}},"404":{"description":"License not found","schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}}}}}}

Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -c /path_to_the/config.json -i http://paht_to_the_swagger_json_above -l php -o /some_destination_path

Steps to reproduce
Related issues
Suggest a Fix

It should only generate one Model per type

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions