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

POST method with application/json & @RequestParam mapped to application/x-www-form-urlencoded #189

Open buraequete opened 6 years ago

buraequete commented 6 years ago

I have the following controller method;

@PostMapping(value = "/{userId}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Response post(@PathVariable String userId, @Valid @RequestBody Item item, @RequestParam String location,
        @RequestParam(required = false) String optional) {
    return new Response().setValue("post");
}

But even though I want it to have application/json type, the resulting RAML has the following broken definition;

post: 
    description: Endpoint returning null, for testing purposes.
    body: 
        application/x-www-form-urlencoded: 
            formParameters: 
                arg1: 
                    displayName: arg1
                    description: arg1
                    type: string
                    required: true
                    repeat: false
                arg2: 
                    displayName: arg2
                    description: arg2
                    type: string
                    required: true
                    repeat: false
               arg3: 
                    displayName: arg3
                    description: arg3
                    type: string
                    required: false
                    repeat: false

When @RequestParam values removed, it maps back to a proper application/json content type endpoint, with proper schema for @RequestBody Item type

Why it does not generate a proper POST definition with both body field with proper schema & queryParameters field with the requestparams?