Open jensbits opened 5 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?
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 thesetupFramework
function ofapi.cfc
that allows you to choose the sort order?Right now I have manually changed the
sortURIMatchOrder
function in theapi.cfc
to show them inasc
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
@atuttle there might be an opportunity for a config option to specify the dashboard/docs display order and integrate that into the core
Currently the function to list the resources on the dashboard and in the docs is
desc
Can there be a
local.defaultConfig
var in thesetupFramework
function ofapi.cfc
that allows you to choose the sort order?Right now I have manually changed the
sortURIMatchOrder
function in theapi.cfc
to show them inasc
order to match the file structure.