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