api-farmer 0.0.13 → 0.0.15
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-IYZKIOO6.js → chunk-LYOTF4II.js} +1 -1
- package/dist/{chunk-PEP3SAL6.js → chunk-VAAFC73D.js} +4 -3
- package/dist/cli.cjs +4 -3
- package/dist/cli.js +2 -2
- package/dist/{generate-UFKCI2ZH.js → generate-RJ23AKV7.js} +2 -2
- package/dist/index.cjs +4 -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
|
*/
|
|
@@ -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,
|
|
@@ -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";
|
|
@@ -22761,6 +22761,7 @@ function transformEntity({ path: path13, method, base }) {
|
|
|
22761
22761
|
if (word.includes("{")) {
|
|
22762
22762
|
return entity;
|
|
22763
22763
|
}
|
|
22764
|
+
word = word.replace(/\.([a-z])/g, (_, p) => p.toUpperCase());
|
|
22764
22765
|
word = pluralize.singular(pascalCase(word));
|
|
22765
22766
|
if (method === "get" && index === words.length - 1) {
|
|
22766
22767
|
word = pluralize.plural(word);
|
|
@@ -22938,8 +22939,8 @@ async function generate(userOptions = {}) {
|
|
|
22938
22939
|
preset = "axle",
|
|
22939
22940
|
statusCodeStrategy = "smart",
|
|
22940
22941
|
input = "./schema.json",
|
|
22941
|
-
output = "./src/apis",
|
|
22942
|
-
typesFilename = "
|
|
22942
|
+
output = "./src/apis/generated",
|
|
22943
|
+
typesFilename = "_types.ts",
|
|
22943
22944
|
transformer = {}
|
|
22944
22945
|
} = options8;
|
|
22945
22946
|
const statusCodes = {
|
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,
|
|
@@ -102045,6 +102045,7 @@ function transformEntity({ path: path13, method, base }) {
|
|
|
102045
102045
|
if (word.includes("{")) {
|
|
102046
102046
|
return entity;
|
|
102047
102047
|
}
|
|
102048
|
+
word = word.replace(/\.([a-z])/g, (_8, p5) => p5.toUpperCase());
|
|
102048
102049
|
word = import_pluralize.default.singular((0, import_rattail.pascalCase)(word));
|
|
102049
102050
|
if (method === "get" && index === words.length - 1) {
|
|
102050
102051
|
word = import_pluralize.default.plural(word);
|
|
@@ -102239,8 +102240,8 @@ async function generate(userOptions = {}) {
|
|
|
102239
102240
|
preset = "axle",
|
|
102240
102241
|
statusCodeStrategy = "smart",
|
|
102241
102242
|
input = "./schema.json",
|
|
102242
|
-
output = "./src/apis",
|
|
102243
|
-
typesFilename = "
|
|
102243
|
+
output = "./src/apis/generated",
|
|
102244
|
+
typesFilename = "_types.ts",
|
|
102244
102245
|
transformer = {}
|
|
102245
102246
|
} = options8;
|
|
102246
102247
|
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-RJ23AKV7.js");
|
|
13
13
|
return generate();
|
|
14
14
|
});
|
|
15
15
|
program.parse();
|
package/dist/index.cjs
CHANGED
|
@@ -79285,6 +79285,7 @@ function transformEntity({ path: path13, method, base }) {
|
|
|
79285
79285
|
if (word.includes("{")) {
|
|
79286
79286
|
return entity;
|
|
79287
79287
|
}
|
|
79288
|
+
word = word.replace(/\.([a-z])/g, (_8, p5) => p5.toUpperCase());
|
|
79288
79289
|
word = import_pluralize.default.singular((0, import_rattail.pascalCase)(word));
|
|
79289
79290
|
if (method === "get" && index === words.length - 1) {
|
|
79290
79291
|
word = import_pluralize.default.plural(word);
|
|
@@ -102148,7 +102149,7 @@ function isRequiredRequestBody(value) {
|
|
|
102148
102149
|
function doStatusCodeStrategy(operation, statusCode, strategy) {
|
|
102149
102150
|
if (strategy === "smart") {
|
|
102150
102151
|
const responses = operation.responses ?? {};
|
|
102151
|
-
const codeKey = Object.keys(responses).sort((a5, b8) => Number(a5) - Number(b8)).find((codeKey2) => Number(codeKey2) >=
|
|
102152
|
+
const codeKey = Object.keys(responses).sort((a5, b8) => Number(a5) - Number(b8)).find((codeKey2) => Number(codeKey2) >= 200 && Number(codeKey2) <= 299);
|
|
102152
102153
|
if (!codeKey) {
|
|
102153
102154
|
return {
|
|
102154
102155
|
statusCode: void 0,
|
|
@@ -102277,8 +102278,8 @@ async function generate(userOptions = {}) {
|
|
|
102277
102278
|
preset = "axle",
|
|
102278
102279
|
statusCodeStrategy = "smart",
|
|
102279
102280
|
input = "./schema.json",
|
|
102280
|
-
output = "./src/apis",
|
|
102281
|
-
typesFilename = "
|
|
102281
|
+
output = "./src/apis/generated",
|
|
102282
|
+
typesFilename = "_types.ts",
|
|
102282
102283
|
transformer = {}
|
|
102283
102284
|
} = options8;
|
|
102284
102285
|
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-VAAFC73D.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
|