Skip to content

Commit 4be9052

Browse files
committed
DEV clean up
1 parent c427225 commit 4be9052

File tree

5 files changed

+113
-68
lines changed

5 files changed

+113
-68
lines changed

src/api/buildApi.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,6 @@ const getExampleResponse = async ({ mockSettings, successExamples = [], errorExa
163163
if (isMissing === false) {
164164
return specExamples;
165165
}
166-
167-
/*
168-
const { paths } = await parseYmlJson({ file: mockSettings.spec });
169-
const availablePaths = await parsePaths(paths, { mockPath: [{ path: url, type }] });
170-
// const specStatus = availablePaths?.[url]?.[type] ? 200 : 404;
171-
const example = await exampleSchemaResponse({
172-
schema: availablePaths?.[url]?.[type],
173-
status: mockSettings.forceStatus
174-
});
175-
176-
return {
177-
authExample: {},
178-
example
179-
/*
180-
example: {
181-
...example,
182-
status: specStatus
183-
}
184-
};
185-
*/
186166
}
187167

188168
return exampleApiDocResponse({ mockSettings, successExamples, errorExamples, type, url });

src/api/parseSpec.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,8 @@ const setResponseExtension = () => {
99
const chance = new Chance();
1010

1111
jsonSchemaFaker.option({
12-
// useExamplesValue: true
13-
// alwaysFakeOptionals: false,
1412
fillProperties: false,
15-
// minDateTime: 30000000000,
1613
reuseProperties: true
17-
// ignoreProperties: true,
18-
// omitNulls: true
19-
// minItems: 1,
20-
// replaceEmptyByRandomValue: true
21-
// minLength: 1
2214
});
2315

2416
jsonSchemaFaker.define('format', (value, schema) => {
@@ -104,7 +96,6 @@ const parseGenerateResponses = ({ requestBody = {}, responses = {} } = {}) => {
10496

10597
const exampleResponse = async ({ schema: valueObj, status: httpStatus, extend: extendFile } = {}) => {
10698
const example = {
107-
// content: { // message: (httpStatus && `Missing example for ${httpStatus} status`) || `Missing example or missing schema.` },
10899
contest: undefined,
109100
contentType: 'application/json',
110101
status: httpStatus
@@ -116,8 +107,6 @@ const exampleResponse = async ({ schema: valueObj, status: httpStatus, extend: e
116107
const { schema } = jsonResponses.find(({ status }) => Number.parseInt(status, 10) === updatedHttpStatus) || {};
117108

118109
if (schema) {
119-
console.log('>>>>>> EXTEND', extendFile);
120-
121110
try {
122111
if (extendFile) {
123112
await setResponseExtensionFile({ file: extendFile });
@@ -134,20 +123,6 @@ const exampleResponse = async ({ schema: valueObj, status: httpStatus, extend: e
134123
}
135124

136125
return example;
137-
/*
138-
Object.entries(paths).forEach(([path, methods]) => {
139-
const updatedPath = replacePathParameters(path);
140-
141-
Object.entries(methods).forEach(([method, valueObj]) => {
142-
const { json: jsonResponses } = parseGenerateResponses(valueObj);
143-
const { schema } = jsonResponses;
144-
jsonSchemaFaker.generate(schema);
145-
routes.push({ method, path: updatedPath });
146-
147-
example
148-
});
149-
});
150-
*/
151126
};
152127

153128
const exampleSchemaResponse = async ({ mockSettings, type, url } = {}) => {
@@ -156,9 +131,6 @@ const exampleSchemaResponse = async ({ mockSettings, type, url } = {}) => {
156131
paths,
157132
mockPath: [{ path: url, type }]
158133
});
159-
// const specStatus = availablePaths?.[url]?.[type] ? 200 : 404;
160-
161-
console.log('>>>>>>>>>>>>>>>>> examplePaths', examplePaths?.[url]?.[type]);
162134
let updatedStatus;
163135

164136
if (/\d/.test(mockSettings.forceStatus)) {
@@ -188,8 +160,6 @@ const exampleSchemaResponse = async ({ mockSettings, type, url } = {}) => {
188160
}
189161
}
190162

191-
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>> USE AVAIL status', updatedStatus);
192-
193163
const example = await exampleResponse({
194164
schema: examplePaths?.[url]?.[type],
195165
status: updatedStatus,

src/api/parseYmlJson.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ const parsePaths = (
6868

6969
if (Array.isArray(mockPath) && mockPath.length) {
7070
const exclusivePaths = {};
71-
// const exclusiveErrorPaths = {};
72-
// const exclusiveSuccessPaths = {};
7371

7472
mockPath.forEach(({ path, type }) => {
7573
const updatedType = type.toLowerCase();
@@ -108,26 +106,17 @@ const parsePaths = (
108106
}
109107
});
110108

111-
// console.log('>>>>>>>>>>>>> PATHS', exclusivePaths[path].get?.responses);
112-
//Object.entries(exclusivePaths).forEach(([key, value]) => {
113-
114-
//});
115-
116109
logger.info(`parse-paths\t:completed ${(Object.keys(exclusivePaths).length < 1 && ':no available paths') || ''}`);
110+
117111
return {
118-
// authPaths: {},
119-
// errorPaths: exclusiveErrorPaths,
120112
examplePaths: exclusivePaths
121-
// successPaths: exclusiveSuccessPaths
122113
};
123114
}
124115

125116
logger.info('parse-paths\t:completed path filtering.');
117+
126118
return {
127-
// authPaths: {},
128-
// errorPaths: {},
129119
examplePaths: updatedAvailablePaths
130-
// successPaths: {}
131120
};
132121
};
133122

src/global.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ const joinUrl = (base, ...args) => {
5353
};
5454

5555
/**
56-
* Simple argument based memoize with adjustable limit. Also allows for promises and
57-
* promise-like functions without co. We don't bother to catch errors, that's the
58-
* consumer's responsibility.
56+
* Simple argument based memoize with adjustable limit that also allows for promises and
57+
* promise-like functions. For promises and promise-like functions it's the consumers
58+
* responsibility to await or process the resolve/reject.
5959
*
6060
* @param {Function} func
6161
* @param {object} options

yarn.lock

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,38 @@
1010
"@jridgewell/gen-mapping" "^0.1.0"
1111
"@jridgewell/trace-mapping" "^0.3.9"
1212

13+
"@apidevtools/[email protected]":
14+
version "9.0.6"
15+
resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.6.tgz#5d9000a3ac1fd25404da886da6b266adcd99cf1c"
16+
integrity sha512-M3YgsLjI0lZxvrpeGVk9Ap032W6TPQkH6pRAZz81Ac3WUNF79VQooAFnp8umjvVzUmD93NkogxEwbSce7qMsUg==
17+
dependencies:
18+
"@jsdevtools/ono" "^7.1.3"
19+
call-me-maybe "^1.0.1"
20+
js-yaml "^3.13.1"
21+
22+
"@apidevtools/openapi-schemas@^2.1.0":
23+
version "2.1.0"
24+
resolved "https://registry.yarnpkg.com/@apidevtools/openapi-schemas/-/openapi-schemas-2.1.0.tgz#9fa08017fb59d80538812f03fc7cac5992caaa17"
25+
integrity sha512-Zc1AlqrJlX3SlpupFGpiLi2EbteyP7fXmUOGup6/DnkRgjP9bgMM/ag+n91rsv0U1Gpz0H3VILA/o3bW7Ua6BQ==
26+
27+
"@apidevtools/swagger-methods@^3.0.2":
28+
version "3.0.2"
29+
resolved "https://registry.yarnpkg.com/@apidevtools/swagger-methods/-/swagger-methods-3.0.2.tgz#b789a362e055b0340d04712eafe7027ddc1ac267"
30+
integrity sha512-QAkD5kK2b1WfjDS/UQn/qQkbwF31uqRjPTrsCs5ZG9BQGAkjwvqGFjjPqAuzac/IYzpPtRzjCP1WrTuAIjMrXg==
31+
32+
"@apidevtools/swagger-parser@^10.1.0":
33+
version "10.1.0"
34+
resolved "https://registry.yarnpkg.com/@apidevtools/swagger-parser/-/swagger-parser-10.1.0.tgz#a987d71e5be61feb623203be0c96e5985b192ab6"
35+
integrity sha512-9Kt7EuS/7WbMAUv2gSziqjvxwDbFSg3Xeyfuj5laUODX8o/k/CpsAKiQ8W7/R88eXFTMbJYg6+7uAmOWNKmwnw==
36+
dependencies:
37+
"@apidevtools/json-schema-ref-parser" "9.0.6"
38+
"@apidevtools/openapi-schemas" "^2.1.0"
39+
"@apidevtools/swagger-methods" "^3.0.2"
40+
"@jsdevtools/ono" "^7.1.3"
41+
ajv "^8.6.3"
42+
ajv-draft-04 "^1.0.0"
43+
call-me-maybe "^1.0.1"
44+
1345
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.18.6":
1446
version "7.18.6"
1547
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a"
@@ -945,6 +977,11 @@
945977
"@jridgewell/resolve-uri" "3.1.0"
946978
"@jridgewell/sourcemap-codec" "1.4.14"
947979

980+
"@jsdevtools/ono@^7.1.3":
981+
version "7.1.3"
982+
resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796"
983+
integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==
984+
948985
"@nodelib/[email protected]":
949986
version "2.1.5"
950987
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -1473,6 +1510,11 @@ aggregate-error@^3.0.0:
14731510
clean-stack "^2.0.0"
14741511
indent-string "^4.0.0"
14751512

1513+
ajv-draft-04@^1.0.0:
1514+
version "1.0.0"
1515+
resolved "https://registry.yarnpkg.com/ajv-draft-04/-/ajv-draft-04-1.0.0.tgz#3b64761b268ba0b9e668f0b41ba53fce0ad77fc8"
1516+
integrity sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==
1517+
14761518
ajv-keywords@^3.5.2:
14771519
version "3.5.2"
14781520
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
@@ -1488,6 +1530,16 @@ ajv@^6.10.0, ajv@^6.11.0, ajv@^6.12.4, ajv@^6.12.5:
14881530
json-schema-traverse "^0.4.1"
14891531
uri-js "^4.2.2"
14901532

1533+
ajv@^8.6.3:
1534+
version "8.12.0"
1535+
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1"
1536+
integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==
1537+
dependencies:
1538+
fast-deep-equal "^3.1.1"
1539+
json-schema-traverse "^1.0.0"
1540+
require-from-string "^2.0.2"
1541+
uri-js "^4.2.2"
1542+
14911543
ansi-align@^3.0.1:
14921544
version "3.0.1"
14931545
resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.1.tgz#0cdf12e111ace773a86e9a1fad1225c43cb19a59"
@@ -1893,6 +1945,11 @@ call-bind@^1.0.0, call-bind@^1.0.2:
18931945
function-bind "^1.1.1"
18941946
get-intrinsic "^1.0.2"
18951947

1948+
call-me-maybe@^1.0.1:
1949+
version "1.0.2"
1950+
resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.2.tgz#03f964f19522ba643b1b0693acb9152fe2074baa"
1951+
integrity sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==
1952+
18961953
callsites@^3.0.0, callsites@^3.1.0:
18971954
version "3.1.0"
18981955
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
@@ -1940,6 +1997,11 @@ chalk@^5.0.1, chalk@^5.2.0:
19401997
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.2.0.tgz#249623b7d66869c673699fb66d65723e54dfcfb3"
19411998
integrity sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA==
19421999

2000+
chance@^1.1.10:
2001+
version "1.1.11"
2002+
resolved "https://registry.yarnpkg.com/chance/-/chance-1.1.11.tgz#78e10e1f9220a5bbc60a83e3f28a5d8558d84d1b"
2003+
integrity sha512-kqTg3WWywappJPqtgrdvbA380VoXO2eu9VCV895JgbyHsaErXdyHK9LOZ911OvAk6L0obK7kDk9CGs8+oBawVA==
2004+
19432005
changelog-light@^0.3.1:
19442006
version "0.3.1"
19452007
resolved "https://registry.yarnpkg.com/changelog-light/-/changelog-light-0.3.1.tgz#b627db5ac19dd9260c5097067cd8a6602cb4001a"
@@ -3300,6 +3362,11 @@ form-data-encoder@^2.1.2:
33003362
resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-2.1.4.tgz#261ea35d2a70d48d30ec7a9603130fa5515e9cd5"
33013363
integrity sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==
33023364

3365+
format-util@^1.0.3:
3366+
version "1.0.5"
3367+
resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271"
3368+
integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==
3369+
33033370
33043371
version "0.2.0"
33053372
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
@@ -4499,7 +4566,7 @@ js-tokens@^4.0.0:
44994566
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
45004567
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
45014568

4502-
js-yaml@^3.13.1:
4569+
js-yaml@^3.12.1, js-yaml@^3.13.1:
45034570
version "3.14.1"
45044571
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
45054572
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
@@ -4551,11 +4618,33 @@ json-parse-helpfulerror@^1.0.3:
45514618
dependencies:
45524619
jju "^1.1.0"
45534620

4621+
json-schema-faker@^0.5.0-rcv.46:
4622+
version "0.5.0-rcv.46"
4623+
resolved "https://registry.yarnpkg.com/json-schema-faker/-/json-schema-faker-0.5.0-rcv.46.tgz#5f9eff94f463c337a361044a460cc46797ceb053"
4624+
integrity sha512-Q+sGrxptZfezwm7M9W9VmHT9E8s5fWPCaRC4J2zUjb3CmDsxokiCBdHdS/psu91Tafc/ITv+GtIztGzUVT2zIg==
4625+
dependencies:
4626+
json-schema-ref-parser "^6.1.0"
4627+
jsonpath-plus "^5.1.0"
4628+
4629+
json-schema-ref-parser@^6.1.0:
4630+
version "6.1.0"
4631+
resolved "https://registry.yarnpkg.com/json-schema-ref-parser/-/json-schema-ref-parser-6.1.0.tgz#30af34aeab5bee0431da805dac0eb21b574bf63d"
4632+
integrity sha512-pXe9H1m6IgIpXmE5JSb8epilNTGsmTb2iPohAXpOdhqGFbQjNeHHsZxU+C8w6T81GZxSPFLeUoqDJmzxx5IGuw==
4633+
dependencies:
4634+
call-me-maybe "^1.0.1"
4635+
js-yaml "^3.12.1"
4636+
ono "^4.0.11"
4637+
45544638
json-schema-traverse@^0.4.1:
45554639
version "0.4.1"
45564640
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
45574641
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
45584642

4643+
json-schema-traverse@^1.0.0:
4644+
version "1.0.0"
4645+
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2"
4646+
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
4647+
45594648
json-stable-stringify-without-jsonify@^1.0.1:
45604649
version "1.0.1"
45614650
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
@@ -4592,6 +4681,11 @@ jsonparse@^1.3.1:
45924681
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
45934682
integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==
45944683

4684+
jsonpath-plus@^5.1.0:
4685+
version "5.1.0"
4686+
resolved "https://registry.yarnpkg.com/jsonpath-plus/-/jsonpath-plus-5.1.0.tgz#2fc4b2e461950626c98525425a3a3518b85af6c3"
4687+
integrity sha512-890w2Pjtj0iswAxalRlt2kHthi6HKrXEfZcn+ZNZptv7F3rUGIeDuZo+C+h4vXBHLEsVjJrHeCm35nYeZLzSBQ==
4688+
45954689
keyv@^4.5.2:
45964690
version "4.5.2"
45974691
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.2.tgz#0e310ce73bf7851ec702f2eaf46ec4e3805cce56"
@@ -4696,6 +4790,11 @@ locate-path@^6.0.0:
46964790
dependencies:
46974791
p-locate "^5.0.0"
46984792

4793+
lodash.clonedeep@^4.5.0:
4794+
version "4.5.0"
4795+
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
4796+
integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==
4797+
46994798
lodash.merge@^4.6.2:
47004799
version "4.6.2"
47014800
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
@@ -4736,7 +4835,7 @@ lru-cache@^6.0.0:
47364835
dependencies:
47374836
yallist "^4.0.0"
47384837

4739-
lru-cache@^7.14.1:
4838+
lru-cache@^7.14.1, lru-cache@^7.17.0:
47404839
version "7.18.3"
47414840
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89"
47424841
integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==
@@ -5351,6 +5450,13 @@ onetime@^5.1.2:
53515450
dependencies:
53525451
mimic-fn "^2.1.0"
53535452

5453+
ono@^4.0.11:
5454+
version "4.0.11"
5455+
resolved "https://registry.yarnpkg.com/ono/-/ono-4.0.11.tgz#c7f4209b3e396e8a44ef43b9cedc7f5d791d221d"
5456+
integrity sha512-jQ31cORBFE6td25deYeD80wxKBMj+zBmHTrVxnc6CKhx8gho6ipmWM5zj/oeoqioZ99yqBls9Z/9Nss7J26G2g==
5457+
dependencies:
5458+
format-util "^1.0.3"
5459+
53545460
optionator@^0.9.1:
53555461
version "0.9.1"
53565462
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499"

0 commit comments

Comments
 (0)