Created by: rubms
PR checklist
-
Read the contribution guidelines. -
Ran the shell script under ./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. -
Filed the PR against the correct branch: master
,3.4.x
,4.0.x
. Default:master
. -
Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
C.C.: @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01)
Description of the PR
Fixed issue #1551 (closed) that caused the generation of invalid default values in Spring MVC annotations for array and map parameters.
In Spring there are 2 different cases with respect to default values:
- The default value specified by the user, that should be included as default value in the Spring MVC API method annotations.
- The default variable initializer (e.g. for model properties), which may be affected by the default value specified by the user but differs in data-types like arrays or maps.
However the Spring code generator uses the same value (the default variable initializer, in my opinion) for both: initializing variables and specifying Spring MVC annotations.
This PR includes an overwrite of fromParameter
for the SpringCodegen class in which the default value for parameters is taken from the one specified by the player. The default value for other types of properties (model properties, for instance) is not modified.