phoenixnap / springmvc-raml-plugin

Spring MVC - RAML Spec Synchroniser Plugin. A Maven plugin designed to Generate Server & Client code in Spring from a RAML API descriptor and conversely, a RAML API document from the SpringMVC Server implementation.
Apache License 2.0
136 stars 84 forks source link

[RAML to code] For MultiPartFile RequestParam name is not added to the annotation #267

Closed thomas-melville closed 6 years ago

thomas-melville commented 6 years ago

Hi,

I'm using your plugin to generate the interface for our controller, thank you very much. There is one thing I see which isn't being generated, the name field in the RequestParam annotation for a MultiPartFile.

I can take an existing unit test as an example. RAML: https://github.com/phoenixnap/springmvc-raml-plugin/blob/466f96e4d2661c6df26b08d48c5d5298992fd0a2/src/test/resources/ramls/test-multipart-mime-request.raml Unit Test: https://github.com/phoenixnap/springmvc-raml-plugin/blob/466f96e4d2661c6df26b08d48c5d5298992fd0a2/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/MultipartMimeRequestTest.java Validation: https://github.com/phoenixnap/springmvc-raml-plugin/blob/466f96e4d2661c6df26b08d48c5d5298992fd0a2/src/test/resources/validations/MultipartRequestStub.java.txt

The generated code is:

@RequestParam
        MultipartFile file

Whereas I would like it to be:

@RequestParam(name = "file")
        MultipartFile file

in my interface

Is this intentional, a missed impact or a bug?

thomas-melville commented 6 years ago

Hi,

I started digging into the code and I see there is a check on this line whether to add the name field to the annotation of not. I'm not sure what the values mean so I will dig into it again tomorrow.

thomas-melville commented 6 years ago

Hi,

We got to the bottom of it. The type definition in the raml began with a lower case letter, when we changed it to start with an uppercase letter it added the name field to the RequestParam annotation. From reading the RAML spec all type declarations starts with an upper case letter so the fault is with me.