From 441cdf4fedf705b54fdd3275d48b876ec5dc09ee Mon Sep 17 00:00:00 2001 From: Dominic Watson Date: Wed, 15 May 2024 18:04:38 +0100 Subject: [PATCH] Fix for #83. Docs sort order is now honoured. --- handlers/rest-apis/data/v1/docs/Html.cfc | 5 ----- services/DataApiSpecService.cfc | 14 +++++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/handlers/rest-apis/data/v1/docs/Html.cfc b/handlers/rest-apis/data/v1/docs/Html.cfc index 2f74e01..8331928 100644 --- a/handlers/rest-apis/data/v1/docs/Html.cfc +++ b/handlers/rest-apis/data/v1/docs/Html.cfc @@ -15,12 +15,7 @@ component { args.spec = variables[ "_spec#api#" ]; -try { - restResponse.setData( Trim( renderView( view="/dataApiHtmlDocs/index", args=args ) ) ); -} catch( any e ) { - WriteDump( e ); abort; -} restResponse.setMimeType( "text/html" ); restResponse.setRenderer( "html" ); } diff --git a/services/DataApiSpecService.cfc b/services/DataApiSpecService.cfc index ba4cb55..363dac5 100644 --- a/services/DataApiSpecService.cfc +++ b/services/DataApiSpecService.cfc @@ -218,10 +218,7 @@ component { parameters = [{name="queueId", in="path", required=true, description=_i18nNamespaced( "dataapi:operation.queue.delete.params.queueId" ), schema={ type="string" } } ] }; } - } - - } private void function _addEntitySpecs( required struct spec ) { @@ -453,9 +450,16 @@ component { }; } } - tags.sort( function( a, b ){ - return a.name > b.name ? 1 : -1; + if ( StructKeyExists( a, "x-sort-order" ) ) { + if ( !StructKeyExists( b, "x-sort-order" ) ) { + return 1; + } else if ( a[ "x-sort-order" ] != b[ "x-sort-order" ] ) { + return a[ "x-sort-order" ] > b[ "x-sort-order" ] ? 1 : -1; + } + } + + return a.name > b.name ? 1 : ( a.name < b.name ? -1 : 0 ); } ); spec.tags.append( tags, true );