I have a route something like this:
// collection GET
fastify.route({
method: 'GET',
url: `${constants.EXTERNAL_PATH}/:serviceName/:collectionName/account/:accountId`,
schema: {
description: 'Get all documents from the specified table for the specified service database and account.',
summary: 'Get all documents from the specified table.',
tags: ['persistence'],
headers: {
$ref: 'authorization-user#'
},
params:{
type: 'object',
properties: {
serviceName: { type: 'string' },
collectionName: { type: 'string' },
accountId: { type: 'string' }
},
required: ['serviceName', 'collectionName', 'accountId'],
},
response: {
200: {
properties: {
'documents': {
description: 'All the retrieved documents from the specified table for the specified service database and account.',
type: 'array',
items: {
$ref: 'persistence-response-doc#',
}
},
},
},
'4xx': {
$ref: 'error-response#',
description: 'Error response'
}
}
},
handler: async (request, reply) => {
// Logic goes here //
}
});
Now my expectation was that:
This should work:
http://localhost:9011/persistence/external/myservice/mycollection/account/my_actn_id
As it has the service as myservice, collection as mycollection and accountId as my_actn_id
However this should fail with a route error (say when I am missing the :accountId, which is required):
http://localhost:9011/persistence/external/myservice/mycollection/account/ <== should fail
However both are passing, returning same collection results.
What am I missing here?
Thanks, Pradip