Skip to content

[Spring] Using property=false behaves as property=true #5637

@ebautistabar

Description

@ebautistabar
Description

Tested in Spring generator, but if the other generators follow the same structure I guess it could happen to them too.

If we set an additional property to false, it behaves like true. For examplle, useBeanValidation=false behaves like useBeanValidation=true, generating validation code. In order not to get validation code, the property must not be included in the command.

I guess the issue is due to mustache evaluating {{#variable}} to true if the variable exists, regardless of its content.

Swagger-codegen version

Latest from master

Command line used for generation

java -jar swagger-codegen-cli.jar generate -i swagger.json -l spring -o build -D hideGenerationTimestamp=true --additional-properties useBeanValidation=false

Steps to reproduce

Execute the given command with a valid JSON file which contains validations.

Suggest a Fix

Read mustache docs to understand why this happens. If mustache templates simply work like this, then we may need to do an explicit removal whenever a property given in the command line is false:

additionalProperties.remove(propertyName);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions