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

Optional queryParameters in subsequent traits are not included in generated code #283

Closed techpavan closed 5 years ago

techpavan commented 5 years ago

In the reproducer project shared below, the request contains a trait named paginationParameters. It has two optional queryParameters and they do not appear in the generated code. But the other metaQuery also has queryParameters which appear in the code even if they are made optional.

Please try different iterations in the reproducer project and identify the issue.

https://github.com/techpavan/springmvc-raml-plugin-issues/tree/master/1

ykarpovets commented 5 years ago

I had the same issue and discovered that it works fine if specify optional parameters using "required: false" instead of short notation using question mark in the end of property name)

stojsavljevic commented 5 years ago

The problem is in raml-parser-2 library. The issue is reported - https://github.com/raml-org/raml-java-parser/issues/411

stojsavljevic commented 5 years ago

There might be a workaround for this issue. Instead of getting data type from response object it should be possible to generate POJOs straight from data types definition at the root of document. I will consider this approach if the issue in raml-parser-2 doesn't get resolved soon.

techpavan commented 5 years ago

The workaround of using required: false instead of short hand notation helps. Good with that for now.