api-farmer 0.0.13 → 0.0.14
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.
- package/README.md +6 -6
- package/dist/{chunk-PEP3SAL6.js → chunk-7HSWACLR.js} +3 -3
- package/dist/{chunk-IYZKIOO6.js → chunk-LYOTF4II.js} +1 -1
- package/dist/cli.cjs +3 -3
- package/dist/cli.js +2 -2
- package/dist/{generate-UFKCI2ZH.js → generate-2D36YQRL.js} +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,8 +36,8 @@ import { defineConfig } from 'api-farmer'
|
|
|
36
36
|
export default defineConfig({
|
|
37
37
|
// openapi or swagger schema path, defaults './schema.json'
|
|
38
38
|
input: './schema.yaml',
|
|
39
|
-
// generated codes output path, defaults './src/apis'
|
|
40
|
-
output: './src/apis',
|
|
39
|
+
// generated codes output path, defaults './src/apis/generated'
|
|
40
|
+
output: './src/apis/generated',
|
|
41
41
|
// 'axle' or 'axios', defaults 'axle'.
|
|
42
42
|
preset: 'axios',
|
|
43
43
|
})
|
|
@@ -242,8 +242,8 @@ export interface ApiModulePayload {
|
|
|
242
242
|
*/
|
|
243
243
|
typeQuery: string
|
|
244
244
|
/**
|
|
245
|
-
* The value of the type of the query parameters of the API endpoint,
|
|
246
|
-
*
|
|
245
|
+
* The value of the type of the query parameters of the API endpoint, such as
|
|
246
|
+
* ApiGetUsersQuery['parameters']['query'], ApiCreatePostQuery['parameters']['query'],
|
|
247
247
|
* ApiUpdateCommentQuery['parameters']['query'], etc.
|
|
248
248
|
*/
|
|
249
249
|
typeQueryValue: string
|
|
@@ -253,8 +253,8 @@ export interface ApiModulePayload {
|
|
|
253
253
|
*/
|
|
254
254
|
typeRequestBody: string
|
|
255
255
|
/**
|
|
256
|
-
* The value of the type of the request body of the API endpoint,
|
|
257
|
-
*
|
|
256
|
+
* The value of the type of the request body of the API endpoint, such as
|
|
257
|
+
* ApiGetUsersRequestBody['requestBody']['content']['application/json'],
|
|
258
258
|
* ApiCreatePostRequestBody['requestBody']['content']['application/json'],
|
|
259
259
|
* ApiUpdateCommentRequestBody['requestBody']['content']['application/json'], etc.
|
|
260
260
|
*/
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isRequiredRequestBody,
|
|
8
8
|
readSchema,
|
|
9
9
|
readTemplateFile
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LYOTF4II.js";
|
|
11
11
|
import {
|
|
12
12
|
__export
|
|
13
13
|
} from "./chunk-6OIOYGN7.js";
|
|
@@ -22938,8 +22938,8 @@ async function generate(userOptions = {}) {
|
|
|
22938
22938
|
preset = "axle",
|
|
22939
22939
|
statusCodeStrategy = "smart",
|
|
22940
22940
|
input = "./schema.json",
|
|
22941
|
-
output = "./src/apis",
|
|
22942
|
-
typesFilename = "
|
|
22941
|
+
output = "./src/apis/generated",
|
|
22942
|
+
typesFilename = "_types.ts",
|
|
22943
22943
|
transformer = {}
|
|
22944
22944
|
} = options8;
|
|
22945
22945
|
const statusCodes = {
|
|
@@ -71,7 +71,7 @@ function isRequiredRequestBody(value) {
|
|
|
71
71
|
function doStatusCodeStrategy(operation, statusCode, strategy) {
|
|
72
72
|
if (strategy === "smart") {
|
|
73
73
|
const responses = operation.responses ?? {};
|
|
74
|
-
const codeKey = Object.keys(responses).sort((a, b) => Number(a) - Number(b)).find((codeKey2) => Number(codeKey2) >=
|
|
74
|
+
const codeKey = Object.keys(responses).sort((a, b) => Number(a) - Number(b)).find((codeKey2) => Number(codeKey2) >= 200 && Number(codeKey2) <= 299);
|
|
75
75
|
if (!codeKey) {
|
|
76
76
|
return {
|
|
77
77
|
statusCode: void 0,
|
package/dist/cli.cjs
CHANGED
|
@@ -112,7 +112,7 @@ function isRequiredRequestBody(value) {
|
|
|
112
112
|
function doStatusCodeStrategy(operation, statusCode, strategy) {
|
|
113
113
|
if (strategy === "smart") {
|
|
114
114
|
const responses = operation.responses ?? {};
|
|
115
|
-
const codeKey = Object.keys(responses).sort((a5, b8) => Number(a5) - Number(b8)).find((codeKey2) => Number(codeKey2) >=
|
|
115
|
+
const codeKey = Object.keys(responses).sort((a5, b8) => Number(a5) - Number(b8)).find((codeKey2) => Number(codeKey2) >= 200 && Number(codeKey2) <= 299);
|
|
116
116
|
if (!codeKey) {
|
|
117
117
|
return {
|
|
118
118
|
statusCode: void 0,
|
|
@@ -102239,8 +102239,8 @@ async function generate(userOptions = {}) {
|
|
|
102239
102239
|
preset = "axle",
|
|
102240
102240
|
statusCodeStrategy = "smart",
|
|
102241
102241
|
input = "./schema.json",
|
|
102242
|
-
output = "./src/apis",
|
|
102243
|
-
typesFilename = "
|
|
102242
|
+
output = "./src/apis/generated",
|
|
102243
|
+
typesFilename = "_types.ts",
|
|
102244
102244
|
transformer = {}
|
|
102245
102245
|
} = options8;
|
|
102246
102246
|
const statusCodes = {
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
getCliVersion
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LYOTF4II.js";
|
|
5
5
|
import "./chunk-6OIOYGN7.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
@@ -9,7 +9,7 @@ import { Command } from "commander";
|
|
|
9
9
|
var program = new Command();
|
|
10
10
|
program.version(getCliVersion());
|
|
11
11
|
program.action(async () => {
|
|
12
|
-
const { generate } = await import("./generate-
|
|
12
|
+
const { generate } = await import("./generate-2D36YQRL.js");
|
|
13
13
|
return generate();
|
|
14
14
|
});
|
|
15
15
|
program.parse();
|
package/dist/index.cjs
CHANGED
|
@@ -102148,7 +102148,7 @@ function isRequiredRequestBody(value) {
|
|
|
102148
102148
|
function doStatusCodeStrategy(operation, statusCode, strategy) {
|
|
102149
102149
|
if (strategy === "smart") {
|
|
102150
102150
|
const responses = operation.responses ?? {};
|
|
102151
|
-
const codeKey = Object.keys(responses).sort((a5, b8) => Number(a5) - Number(b8)).find((codeKey2) => Number(codeKey2) >=
|
|
102151
|
+
const codeKey = Object.keys(responses).sort((a5, b8) => Number(a5) - Number(b8)).find((codeKey2) => Number(codeKey2) >= 200 && Number(codeKey2) <= 299);
|
|
102152
102152
|
if (!codeKey) {
|
|
102153
102153
|
return {
|
|
102154
102154
|
statusCode: void 0,
|
|
@@ -102277,8 +102277,8 @@ async function generate(userOptions = {}) {
|
|
|
102277
102277
|
preset = "axle",
|
|
102278
102278
|
statusCodeStrategy = "smart",
|
|
102279
102279
|
input = "./schema.json",
|
|
102280
|
-
output = "./src/apis",
|
|
102281
|
-
typesFilename = "
|
|
102280
|
+
output = "./src/apis/generated",
|
|
102281
|
+
typesFilename = "_types.ts",
|
|
102282
102282
|
transformer = {}
|
|
102283
102283
|
} = options8;
|
|
102284
102284
|
const statusCodes = {
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
transformTypeValue,
|
|
21
21
|
transformUrl,
|
|
22
22
|
transformVerb
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-7HSWACLR.js";
|
|
24
24
|
import {
|
|
25
25
|
createStatusCodesByStrategy,
|
|
26
26
|
doStatusCodeStrategy,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
isRequiredRequestBody,
|
|
30
30
|
readSchema,
|
|
31
31
|
readTemplateFile
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-LYOTF4II.js";
|
|
33
33
|
import "./chunk-6OIOYGN7.js";
|
|
34
34
|
|
|
35
35
|
// src/index.ts
|