diff --git a/packages/http-mock-gen/package.json b/packages/http-mock-gen/package.json index a55c1af..c06a964 100644 --- a/packages/http-mock-gen/package.json +++ b/packages/http-mock-gen/package.json @@ -47,7 +47,7 @@ "commander": "^10.0.1", "express": "^4.18.2", "fs-extra": "^11.1.1", - "json-schema-faker": "^0.5.0-rcv.46" + "@liangskyli/json-schema-faker": "^0.5.0-rcv.48" }, "devDependencies": { "@liangskyli/http-mock-gen": "workspace:*" diff --git a/packages/http-mock-gen/src/gen/file/gen-mock-data-json.ts b/packages/http-mock-gen/src/gen/file/gen-mock-data-json.ts index 9233fc9..2ff44c8 100644 --- a/packages/http-mock-gen/src/gen/file/gen-mock-data-json.ts +++ b/packages/http-mock-gen/src/gen/file/gen-mock-data-json.ts @@ -1,8 +1,11 @@ +import type { + JSONSchemaFakerOptions, + Schema, +} from '@liangskyli/json-schema-faker'; +import { JSONSchemaFaker } from '@liangskyli/json-schema-faker'; import type { Definition } from '@liangskyli/openapi-gen-ts'; import type { IPrettierOptions } from '@liangskyli/utils'; import { copyOptions } from '@liangskyli/utils'; -import type { JSONSchemaFakerOptions, Schema } from 'json-schema-faker'; -import { JSONSchemaFaker } from 'json-schema-faker'; import path from 'path'; import { writePrettierFile } from '../../utils'; diff --git a/packages/http-mock-gen/src/gen/index.ts b/packages/http-mock-gen/src/gen/index.ts index 915c064..5087123 100644 --- a/packages/http-mock-gen/src/gen/index.ts +++ b/packages/http-mock-gen/src/gen/index.ts @@ -1,3 +1,4 @@ +import type { JSONSchemaFakerOptions } from '@liangskyli/json-schema-faker'; import type { IGenTsDataOpts } from '@liangskyli/openapi-gen-ts'; import genTsData from '@liangskyli/openapi-gen-ts'; import { @@ -7,7 +8,6 @@ import { removeFilesSync, } from '@liangskyli/utils'; import fs from 'fs-extra'; -import type { JSONSchemaFakerOptions } from 'json-schema-faker'; import path from 'path'; import generatorMockFile from './file'; diff --git a/packages/http-mock-gen/test/gen/file/__test__snapshots__/mock-data.json b/packages/http-mock-gen/test/gen/file/__test__snapshots__/mock-data.json new file mode 100644 index 0000000..ccb14f8 --- /dev/null +++ b/packages/http-mock-gen/test/gen/file/__test__snapshots__/mock-data.json @@ -0,0 +1,26 @@ +{ + "/root/v4/getQueryParams1-v4": { + "get": { + "parameters": { + "query": { + "activityBases": [ + { + "activityId": 0, + "activityName": "activityName", + "customerCount": 0, + "roomCount": 0, + "isException": false + } + ] + } + }, + "responses": { + "200": { + "content": { + "text/plain": "text/plain" + } + } + } + } + } +} diff --git a/packages/http-mock-gen/test/gen/file/gen-mock-data-json.test.ts b/packages/http-mock-gen/test/gen/file/gen-mock-data-json.test.ts index b23c5c7..bb388fe 100644 --- a/packages/http-mock-gen/test/gen/file/gen-mock-data-json.test.ts +++ b/packages/http-mock-gen/test/gen/file/gen-mock-data-json.test.ts @@ -60,9 +60,7 @@ describe('Generate mock/mock-data.json file', () => { ); expect(mockDataAbsolutePath).toBe(args[0] as string); expect(args[1]).contains('"/root/v4/getQueryParams1-v4"'); - /*await expect(args[1]).toMatchFileSnapshot( - './__test__snapshots__/schema.json', - );*/ + expect(args[1]).toMatchFileSnapshot('./__test__snapshots__/mock-data.json'); expect((global as any).writePrettierFileArgs.prettierOptions).toEqual({ parser: 'json', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac326ec..72472ab 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,6 +138,9 @@ importers: packages/http-mock-gen: dependencies: + '@liangskyli/json-schema-faker': + specifier: ^0.5.0-rcv.48 + version: 0.5.0-rcv.48 '@liangskyli/openapi-gen-ts': specifier: ^1.0.1 version: 1.0.1 @@ -162,9 +165,6 @@ importers: fs-extra: specifier: ^11.1.1 version: 11.1.1 - json-schema-faker: - specifier: ^0.5.0-rcv.46 - version: 0.5.0-rcv.46 devDependencies: '@liangskyli/http-mock-gen': specifier: workspace:* @@ -1362,6 +1362,11 @@ packages: - supports-color dev: true + /@liangskyli/json-schema-faker@0.5.0-rcv.48: + resolution: {integrity: sha512-BMp0ton8tg2O3YARem2bvnARjb1PpjL0ZiOnoUKdfvHl6Ra6reYGAGokIF4EaYgIyTV2m6uus1yrEKOF8p3tHg==} + hasBin: true + dev: false + /@liangskyli/openapi-gen-ts@1.0.1: resolution: {integrity: sha512-9ysiRKffLh235HTUaZpQ6pMo5WhTofx16c0ZF2IflBNtbjI3g2gx1Pu0VzmZLoez1kjZSyUHG04hsqgKbPNz2Q==} engines: {node: '>=16.8.0'} @@ -3102,6 +3107,7 @@ packages: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} dependencies: sprintf-js: 1.0.3 + dev: true /argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -3514,10 +3520,6 @@ packages: function-bind: 1.1.1 get-intrinsic: 1.2.0 - /call-me-maybe@1.0.1: - resolution: {integrity: sha512-wCyFsDQkKPwwF8BDwOiWNx/9K45L/hvggQiDbve+viMNMQnWhrlYIuBk09offfwCRtCO9P6XwUttufzU11WCVw==} - dev: false - /callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -4801,6 +4803,7 @@ packages: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} engines: {node: '>=4'} hasBin: true + dev: true /esquery@1.5.0: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} @@ -5142,10 +5145,6 @@ packages: combined-stream: 1.0.8 mime-types: 2.1.35 - /format-util@1.0.5: - resolution: {integrity: sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==} - dev: false - /forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -6357,6 +6356,7 @@ packages: dependencies: argparse: 1.0.10 esprima: 4.0.1 + dev: true /js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} @@ -6382,22 +6382,6 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} dev: true - /json-schema-faker@0.5.0-rcv.46: - resolution: {integrity: sha512-Q+sGrxptZfezwm7M9W9VmHT9E8s5fWPCaRC4J2zUjb3CmDsxokiCBdHdS/psu91Tafc/ITv+GtIztGzUVT2zIg==} - hasBin: true - dependencies: - json-schema-ref-parser: 6.1.0 - jsonpath-plus: 5.1.0 - dev: false - - /json-schema-ref-parser@6.1.0: - resolution: {integrity: sha512-pXe9H1m6IgIpXmE5JSb8epilNTGsmTb2iPohAXpOdhqGFbQjNeHHsZxU+C8w6T81GZxSPFLeUoqDJmzxx5IGuw==} - dependencies: - call-me-maybe: 1.0.1 - js-yaml: 3.14.1 - ono: 4.0.11 - dev: false - /json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} dev: true @@ -6446,11 +6430,6 @@ packages: engines: {'0': node >= 0.2.0} dev: true - /jsonpath-plus@5.1.0: - resolution: {integrity: sha512-890w2Pjtj0iswAxalRlt2kHthi6HKrXEfZcn+ZNZptv7F3rUGIeDuZo+C+h4vXBHLEsVjJrHeCm35nYeZLzSBQ==} - engines: {node: '>=10.0.0'} - dev: false - /jsx-ast-utils@3.3.3: resolution: {integrity: sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw==} engines: {node: '>=4.0'} @@ -7749,12 +7728,6 @@ packages: mimic-fn: 4.0.0 dev: true - /ono@4.0.11: - resolution: {integrity: sha512-jQ31cORBFE6td25deYeD80wxKBMj+zBmHTrVxnc6CKhx8gho6ipmWM5zj/oeoqioZ99yqBls9Z/9Nss7J26G2g==} - dependencies: - format-util: 1.0.5 - dev: false - /open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} @@ -9283,6 +9256,7 @@ packages: /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + dev: true /ssri@10.0.4: resolution: {integrity: sha512-12+IR2CB2C28MMAw0Ncqwj5QbTcs0nGIhgJzYWzDkb21vWmfNI83KS4f3Ci6GI98WreIfG7o9UXp3C0qbpA8nQ==}