Skip to content

Commit

Permalink
Fix for #83. Docs sort order is now honoured.
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed May 15, 2024
1 parent 80a998e commit 441cdf4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 0 additions & 5 deletions handlers/rest-apis/data/v1/docs/Html.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
}
Expand Down
14 changes: 9 additions & 5 deletions services/DataApiSpecService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 441cdf4

Please sign in to comment.