stoicflame / enunciate

Build-time enhancement tool for Java-based Web services projects
http://enunciate.webcohesion.com/
Other
481 stars 201 forks source link

v2 template: Order of resources #126

Closed anton-johansson closed 9 years ago

anton-johansson commented 9 years ago

In the new template for Enunciate version 2, the resources seems to be ordered by their services class name. Is there any possibility to order them by the service classes @Path annotation? At least in my case, it would give me a much better order of the resources.

stoicflame commented 9 years ago

Yes, you can group by path:

<enunciate>
  <modules>
    <jaxrs groupBy="path"/>

Is that what you were looking for?

anton-johansson commented 9 years ago

I tried that, but it didn't give me the results I was looking for. Diving into the code, it doesn't look like this is what I'm after either. The grouping is not an issue, but rather the order of the groups.

Let me explain using an image: docs order

Here we have three service classes. We have divided our operations into various scopes, depending on the usage. /estore serves data from a NoSQL layer, while /admin serves data directly to the master relational database.

However, we don't currently prefix the classes "Estore" and "Admin". So the three service classes are actually called:

I would like to see the CategoryService being sorted after the other two services, according to the @Path annotation order.

We might be better of just prefixing the service classes properly, but I still think the proper order should be according to @Path. What do you think?

stoicflame commented 9 years ago

Oh, I see. That makes sense. Yes, I think the path-based sorting seems reasonable. I'll get it fixed.

stoicflame commented 9 years ago

Fixed at b7b4b57.

stoicflame commented 9 years ago

Fix was included in Milestone 4.

In order to not dictate the sort order, the @com.webcohesion.enunciate.metadata.rs.ResourceLabel annotation was enhanced to provide a sortKey that can be used to fix the sorting algorithm of each resource group.