ml-testing-toolkit 18.14.2 → 18.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ {
2
+ "/parties/{idType}/{idValue}": {
3
+ "get": {
4
+ "response": {
5
+ "bodyOverride": {
6
+ "idType": "{$request.params.idType}",
7
+ "idValue": "{$request.params.idValue}",
8
+ "merchantClassificationCode": null
9
+ }
10
+ }
11
+ }
12
+ },
13
+ "/quoterequests": {
14
+ "post": {
15
+ "response": {
16
+ "bodyOverride": {
17
+ "quoteId": "{$request.body.quoteId}",
18
+ "transactionId": "{$request.body.transactionId}",
19
+ "transferAmount": "{$request.body.amount}",
20
+ "transferAmountCurrency": "{$request.body.currency}",
21
+ "expiration": "{$request.body.expiration}",
22
+ "geoCode": null,
23
+ "extensionList": null
24
+ }
25
+ }
26
+ }
27
+ },
28
+ "/transfers": {
29
+ "post": {
30
+ "response": {
31
+ "bodyOverride": {
32
+ "homeTransactionId": "{$request.body.transferId}"
33
+ }
34
+ }
35
+ }
36
+ },
37
+ "/bulkQuotes": {
38
+ "post": {
39
+ "response": {
40
+ "bodyOverride": {
41
+ "bulkQuoteId": "{$request.body.bulkQuoteId}"
42
+ }
43
+ }
44
+ }
45
+ },
46
+ "/bulkTransfers": {
47
+ "post": {
48
+ "response": {
49
+ "bodyOverride": {
50
+ "bulkTransferId": "{$request.body.bulkTransferId}"
51
+ }
52
+ }
53
+ }
54
+ },
55
+ "/bulkTransactions/{bulkTransactionId}": {
56
+ "put": {
57
+ "response": {}
58
+ }
59
+ }
60
+ }
@@ -29,6 +29,7 @@
29
29
 
30
30
  const addFormats = require('ajv-formats')
31
31
  const OpenApiBackend = require('openapi-backend').default
32
+ const fs = require('node:fs')
32
33
  const Utils = require('./utils')
33
34
  const path = require('path')
34
35
  const Config = require('./config')
@@ -37,9 +38,24 @@ const OpenApiMockHandler = require('./mocking/openApiMockHandler')
37
38
 
38
39
  const apiDefinitionsPath = 'spec_files/api_definitions/'
39
40
 
41
+ // check if the file contains URL and return it instead of the file name
42
+ const checkUrl = async fileName => {
43
+ const buffer = Buffer.alloc(10)
44
+ const fileHandle = await fs.promises.open(fileName, 'r')
45
+ try {
46
+ await fileHandle.read(buffer, 0, 10, 0)
47
+ } finally {
48
+ await fileHandle.close()
49
+ }
50
+ const prefix = buffer.toString('utf8').replace('\uFEFF', '') // Remove BOM
51
+ return (prefix.startsWith('"http'))
52
+ ? JSON.parse(fs.readFileSync(fileName).toString('utf8'))
53
+ : fileName
54
+ }
55
+
40
56
  const validateDefinition = async (apiFilePath) => {
41
57
  const newApi = new OpenApiBackend({
42
- definition: path.join(apiFilePath),
58
+ definition: await checkUrl(path.join(apiFilePath)),
43
59
  customizeAjv: ajv => addFormats(ajv),
44
60
  strict: true,
45
61
  quick: true