Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jensbits opened this issue Dec 10, 2018 · 3 comments
Open

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

jensbits opened this issue Dec 10, 2018 · 3 comments

Comments

@jensbits
Copy link

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
Copy link
Owner

atuttle commented Oct 1, 2020

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants