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

Duplicate methods getting created in the Generated Java code #251

Closed techpavan closed 6 years ago

techpavan commented 6 years ago

This is reproducible with the below RAML.

%RAML 1.0

title: Ops version: v1

/ops: /op1/{id}: post:

/op2/{id}: post:

/{userId}: /op1/{id}: post:

/op2/{id}: post:

image

stojsavljevic commented 6 years ago

Hi @techpavan

Naming logic got changed in v2.0. Now it's driven by request parameters and actual objects returned. Previously, it was driven by resource names.

New logic has more sense and leads to better naming IMHO but in some cases it might lead to duplicate method names as you pointed out. But in some real life scenario I don't expect this will happen. At least not too often. But in order to workaround this issue I implemented #250 So, for methods which name you want to change you can use either displayName attribute or annotation called javaName (you need to define it in a raml).

Hope this helps! If you still see some downsides of this approach feel free to open the issue.

techpavan commented 6 years ago

Hi @stojsavljevic ,

Thanks for the decent workaround and I could tackle it with displayName. For your information, I encountered this issue in my real life application, just created a simpler reproducer to raise the issue on the public domain.

techpavan commented 6 years ago

Wondering about the versioning. The one in your pom.xml is 2.0.1 and not a snapshot. Was it a miss?

stojsavljevic commented 6 years ago

We're not using snapshots. The feature I talked about (better naming control with displayName attribute and custom annotation) is not yet released. It will be part of 2.0.1 . I'm considering adding one more feature before I release new version.