jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/361926 )
Change subject: Move the /list/:tool/ to the end of routes/v1.js ...................................................................... Move the /list/:tool/ to the end of routes/v1.js Route matching in express executes the first match it finds for the incoming request's path. /list/:tool/ matches any path starting with /list/, including /list/pair/ and /list/languagepairs, if the route is defined earlier in the file, making the latter routes unreachable code. Hence, declare these routes before /list/:tool. Change-Id: I8732c369d2e8f1950e3fa2f13204d64571e9574c --- M routes/v1.js M spec.yaml 2 files changed, 60 insertions(+), 60 deletions(-) Approvals: KartikMistry: Looks good to me, approved jenkins-bot: Verified diff --git a/routes/v1.js b/routes/v1.js index dff6956..8203f97 100644 --- a/routes/v1.js +++ b/routes/v1.js @@ -141,28 +141,6 @@ ); } ); -router.get( '/list/:tool/:from?/:to?', function ( req, res ) { - var toolset, result = {}, - tool = req.params.tool, - from = req.params.from, - to = req.params.to; - - registry = require( __dirname + '/../registry' )( app ); - if ( from && to ) { - toolset = registry.getToolSet( from, to ); - result[ tool ] = toolset[ tool ]; - result[ 'default' ] = toolset.default; - } else if ( tool ) { - if ( tool === 'mt' ) { - result = registry.getMTPairs(); - } - if ( tool === 'dictionary' ) { - result = registry.getDictionaryPairs(); - } - } - res.json( result ); -} ); - /** * Get a list of all language pairs that tool supports. */ @@ -216,6 +194,28 @@ res.json( registry.getLanguagePairs() ); } ); +router.get( '/list/:tool/:from?/:to?', function ( req, res ) { + var toolset, result = {}, + tool = req.params.tool, + from = req.params.from, + to = req.params.to; + + registry = require( __dirname + '/../registry' )( app ); + if ( from && to ) { + toolset = registry.getToolSet( from, to ); + result[ tool ] = toolset[ tool ]; + result[ 'default' ] = toolset.default; + } else if ( tool ) { + if ( tool === 'mt' ) { + result = registry.getMTPairs(); + } + if ( tool === 'dictionary' ) { + result = registry.getDictionaryPairs(); + } + } + res.json( result ); +} ); + module.exports = function ( appObj ) { app = appObj; return { diff --git a/spec.yaml b/spec.yaml index ab5766c..11b8aae 100644 --- a/spec.yaml +++ b/spec.yaml @@ -226,44 +226,6 @@ status: 200 headers: content-type: application/json - /v1/list/{tool}{/from}{/to}: - get: - tags: - - Tools - - Service information - description: Lists all language pairs that tool supports - produces: - - application/json - parameters: - - name: tool - in: path - description: The tool name - type: string - required: true - enum: - - mt - - dictionary - - name: from - in: path - description: The source language code - type: string - required: false - - name: to - in: path - description: The target language code - type: string - required: false - x-amples: - - title: Get the MT tool between two language pairs - request: - params: - from: en - to: es - tool: mt - response: - status: 200 - headers: - content-type: application/json /v1/list/pair/{from}/{to}: get: tags: @@ -306,6 +268,44 @@ status: 200 headers: content-type: application/json + /v1/list/{tool}{/from}{/to}: + get: + tags: + - Tools + - Service information + description: Lists all language pairs that tool supports + produces: + - application/json + parameters: + - name: tool + in: path + description: The tool name + type: string + required: true + enum: + - mt + - dictionary + - name: from + in: path + description: The source language code + type: string + required: false + - name: to + in: path + description: The target language code + type: string + required: false + x-amples: + - title: Get the MT tool between two language pairs + request: + params: + from: en + to: es + tool: mt + response: + status: 200 + headers: + content-type: application/json /v1/languagepairs: get: tags: -- To view, visit https://gerrit.wikimedia.org/r/361926 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8732c369d2e8f1950e3fa2f13204d64571e9574c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/cxserver Gerrit-Branch: master Gerrit-Owner: Mobrovac <mobro...@wikimedia.org> Gerrit-Reviewer: KartikMistry <kartik.mis...@gmail.com> Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits