Open yuranos opened 6 years ago
Just to make something clear:
/errors/{errorId}:
produces ErrorIdErrorController
while
/errors:
/{errorId}:
produces ErrorController
.
Am I correct @yuranos?
Bear in mind that path variable influences this behavior since for:
/abc:
/efg:
and
/abc/efg:
it's always the same - EfgAbcController
.
So I'm not sure what kind of 'reverse traversal' you have in mind.
There is already reverseOrderInClassNames
config option which can control the way controller names are generated. With <reverseOrderInClassNames>false</reverseOrderInClassNames>
you'll get AbcEfgController
instead.
@stojsavljevic , are you talking about RAML 1.0?
I have just tried reverseOrderInClassNames
option for both:
/errors:
/mycontroller:
post:
description: Checks and adds booking to customer
queryParameters:
siteKey : SiteKey
body:
application/json:
type: AddBookingRequest
responses:
201:
body:
application/json:
type: BookingDetailsDto
and
/errors/mycontroller:
post:
description: Checks and adds booking to customer
queryParameters:
siteKey : SiteKey
body:
application/json:
type: AddBookingRequest
responses:
201:
body:
application/json:
type: BookingDetailsDto
and the resulting name is always the same:
MycontrollerController
To be honest, I was not aware of that option, but it seems not to work as expected, or my expectation is different to the designed one.
I also haven't seen anything like EfgAbcController
. As you can see in my example, class name always contains only one segment. What are we doing differently?
Sorry I didn't explain it well.
So there are 2 config options:
resourceDepthInClassNames
- number of resource levels used for controller name generation; default is 1
reverseOrderInClassNames
- option to reverse the order of resource levels used for name generation. Obviously, you need to have resourceDepthInClassNames
> 1 for this option to have impact; default is false
I was using resourceDepthInClassNames=2
and reverseOrderInClassNames=true
in my abc/efg
example. Sorry for the confusion.
To get back to your original question - we can consider ErrorIdController
name a bug. It should be ErrorController
like with:
/errors:
/{errorId}
At the moment, the very last segment inside the root path is taken as a basis for controller name: RAML:
would generate controller named:
ErrorIdController
(it was actually errorIdController, just a couple of days ago before #215 fix). While it's not critical and can easily be circumvented with:wouldn't it be nice to be able to set a flag inside a plugin that will use a reverse traversal for Controller naming? What do you think, guys?