atuttle / Taffy

:candy: The REST Web Service framework for ColdFusion and Lucee
http://taffy.io
Other
226 stars 118 forks source link

Ability to reverse order of resources on dashboard and documents #382

Open jensbits opened 5 years ago

jensbits commented 5 years ago

Currently the function to list the resources on the dashboard and in the docs is desc

<cffunction name="sortURIMatchOrder" access="private" output="false">
    <cfargument name="endpoints" />
    <cfset var URIMatchOrder = listToArray( structKeyList(arguments.endpoints, chr(10)), chr(10) ) />
    <cfset arraySort(URIMatchOrder, "text", "desc") />
    <cfreturn URIMatchOrder />
</cffunction>

Can there be a local.defaultConfig var in the setupFramework function of api.cfc that allows you to choose the sort order?

Right now I have manually changed the sortURIMatchOrder function in the api.cfc to show them in asc order to match the file structure.

atuttle commented 4 years ago

As described on the dashboard page footer, resources are currently listed in matching order. It's possible to create multiple resources that could, by using simple tokens, all match the same incoming request URL.

For example, if you had these two resources: /books/green and /books/{bookId}. Taffy lets you do it because it considers green to be more specific than {bookId} so it checks for matching against /books/green first. For that reason, /books/green would show up above /books/{bookId} in the dashboard. This is to help developers understand how Taffy is thinking about the URIs they specify.

I understand that we have some competing priorities in play here. The matching order is useful information to have for the api developers, but the average api consumer doesn't really care about that. I'm very open to ideas on how we can serve both audiences well.

For what it's worth, there are other efforts in progress to bring something like a dynamic filter-as-you-type feature to the dashboard. Would that be useful enough that the sort order is less important?

reynacho commented 1 year ago

Currently the function to list the resources on the dashboard and in the docs is desc

<cffunction name="sortURIMatchOrder" access="private" output="false">
  <cfargument name="endpoints" />
  <cfset var URIMatchOrder = listToArray( structKeyList(arguments.endpoints, chr(10)), chr(10) ) />
  <cfset arraySort(URIMatchOrder, "text", "desc") />
  <cfreturn URIMatchOrder />
</cffunction>

Can there be a local.defaultConfig var in the setupFramework function of api.cfc that allows you to choose the sort order?

Right now I have manually changed the sortURIMatchOrder function in the api.cfc to show them in asc order to match the file structure.

I needed to do something similar and I found there's a docspath in the config so in my variables.framework I set variables.framework.docsPath = "/v1/docs.cfm"; I copied the docs.cfm from /taffy/dashboard. Then all the included CSS/JS files just need to have /taffy/dashboard/ added to them, or wherever you installed taffy. Then around line 27 of the docs.cfm file, just reverse the array: <cfloop from="#arrayLen(application._taffy.uriMatchOrder)#" to="1" step="-1" index="local.resource"> This accomplishes the display of endpoints in reverse order for clients, but doesn't change the underlying logic in place in the core api

reynacho commented 1 year ago

@atuttle there might be an opportunity for a config option to specify the dashboard/docs display order and integrate that into the core