swagger-typescript-api 13.0.7 → 13.0.9
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 +1 -1
- package/cli/constants.js +1 -5
- package/cli/execute.js +5 -7
- package/cli/index.d.ts +7 -6
- package/cli/index.js +7 -9
- package/cli/operations/display-help.js +3 -5
- package/cli/operations/display-version.js +1 -1
- package/cli/parse-args.js +1 -3
- package/cli/process-option.js +2 -4
- package/index.js +11 -16
- package/package.json +12 -6
- package/src/code-formatter.js +5 -7
- package/src/code-gen-process.js +20 -22
- package/src/commands/generate-templates/configuration.js +3 -5
- package/src/commands/generate-templates/index.js +6 -12
- package/src/commands/generate-templates/templates-gen-process.js +8 -7
- package/src/component-type-name-resolver.js +3 -5
- package/src/configuration.js +8 -11
- package/src/constants.js +48 -36
- package/src/index.js +12 -22
- package/src/schema-components-map.js +2 -4
- package/src/schema-parser/base-schema-parsers/array.js +4 -6
- package/src/schema-parser/base-schema-parsers/complex.js +4 -6
- package/src/schema-parser/base-schema-parsers/discriminator.js +4 -6
- package/src/schema-parser/base-schema-parsers/enum.js +6 -8
- package/src/schema-parser/base-schema-parsers/object.js +4 -6
- package/src/schema-parser/base-schema-parsers/primitive.js +4 -6
- package/src/schema-parser/complex-schema-parsers/all-of.js +3 -3
- package/src/schema-parser/complex-schema-parsers/any-of.js +3 -3
- package/src/schema-parser/complex-schema-parsers/not.js +2 -2
- package/src/schema-parser/complex-schema-parsers/one-of.js +3 -3
- package/src/schema-parser/mono-schema-parser.js +1 -3
- package/src/schema-parser/schema-formatters.js +4 -6
- package/src/schema-parser/schema-parser-fabric.js +5 -7
- package/src/schema-parser/schema-parser.js +17 -25
- package/src/schema-parser/schema-utils.js +9 -14
- package/src/schema-parser/util/enum-key-resolver.js +2 -4
- package/src/schema-routes/schema-routes.js +13 -27
- package/src/schema-routes/util/specific-arg-name-resolver.js +2 -4
- package/src/schema-walker.js +2 -4
- package/src/swagger-schema-resolver.js +5 -7
- package/src/templates-worker.js +7 -7
- package/src/translators/javascript.js +3 -5
- package/src/translators/translator.js +1 -3
- package/src/type-name-formatter.js +2 -4
- package/src/util/file-system.js +8 -8
- package/src/util/id.js +2 -4
- package/src/util/internal-case.js +6 -4
- package/src/util/logger.js +3 -5
- package/src/util/name-resolver.js +2 -4
- package/src/util/object-assign.js +2 -4
- package/src/util/pascal-case.js +6 -4
- package/src/util/random.js +1 -4
- package/src/util/request.js +2 -4
- package/src/util/sort-by-property.js +1 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# swagger-typescript-api
|
|
2
2
|
|
|
3
3
|
- Support for OpenAPI 3.0, 2.0, JSON and YAML
|
|
4
|
-
- Generate the API
|
|
4
|
+
- Generate the API Client for Fetch or Axios from an OpenAPI Specification
|
|
5
5
|
|
|
6
6
|
Any questions you can ask [**here**](https://github.com/acacode/swagger-typescript-api/discussions)
|
|
7
7
|
|
package/cli/constants.js
CHANGED
package/cli/execute.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import didYouMean from "didyoumean";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import { root_command, skip_command } from "./constants.js";
|
|
4
|
+
import { parseArgs } from "./parse-args.js";
|
|
5
5
|
|
|
6
6
|
didYouMean.threshold = 0.5;
|
|
7
7
|
|
|
@@ -177,6 +177,4 @@ const processArgs = (commands, args) => {
|
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
execute,
|
|
182
|
-
};
|
|
180
|
+
export { execute };
|
package/cli/index.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
type CliStructOption = {
|
|
2
|
-
flags?: string;
|
|
3
|
-
description?: string;
|
|
4
2
|
default?: unknown;
|
|
3
|
+
description?: string;
|
|
4
|
+
flags?: string;
|
|
5
5
|
internal?: { name?: string; formatter?: (value: any) => any };
|
|
6
|
+
required?: boolean;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
type CliStruct = {
|
|
9
|
-
inherited?: string | null;
|
|
10
|
-
name?: string;
|
|
11
10
|
alias?: string;
|
|
12
|
-
|
|
11
|
+
commands?: CliStruct[];
|
|
13
12
|
description?: string;
|
|
13
|
+
inherited?: string | null;
|
|
14
|
+
name?: string;
|
|
14
15
|
options: CliStructOption[];
|
|
15
|
-
|
|
16
|
+
version?: string;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
type ExecuteOptions = {
|
package/cli/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { reservedOptions, root_command } from "./constants.js";
|
|
3
|
+
import { execute } from "./execute.js";
|
|
4
|
+
import { displayHelp } from "./operations/display-help.js";
|
|
5
|
+
import { displayVersion } from "./operations/display-version.js";
|
|
6
|
+
import { processOption } from "./process-option.js";
|
|
7
7
|
|
|
8
8
|
const cli = (input) => {
|
|
9
9
|
const commands = {};
|
|
@@ -91,6 +91,4 @@ const cli = (input) => {
|
|
|
91
91
|
return instance;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
cli,
|
|
96
|
-
};
|
|
94
|
+
export { cli };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { root_command } from "../constants.js";
|
|
3
3
|
|
|
4
4
|
const generateOptionsOutput = (options) =>
|
|
5
5
|
options.reduce(
|
|
@@ -174,6 +174,4 @@ ${command.description}`
|
|
|
174
174
|
${outputTest}`);
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
displayHelp,
|
|
179
|
-
};
|
|
177
|
+
export { displayHelp };
|
package/cli/parse-args.js
CHANGED
package/cli/process-option.js
CHANGED
package/index.js
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { cli } from "./cli/index.js";
|
|
6
|
+
import { TemplatesGenConfig } from "./src/commands/generate-templates/configuration.js";
|
|
7
|
+
import { CodeGenConfig } from "./src/configuration.js";
|
|
8
|
+
import { HTTP_CLIENT } from "./src/constants.js";
|
|
9
|
+
import { generateApi, generateTemplates } from "./src/index.js";
|
|
8
10
|
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const { generateApi, generateTemplates } = require("./src");
|
|
12
|
-
const { HTTP_CLIENT } = require("./src/constants");
|
|
13
|
-
const { resolve } = require("node:path");
|
|
14
|
-
const { CodeGenConfig } = require("./src/configuration");
|
|
15
|
-
const {
|
|
16
|
-
TemplatesGenConfig,
|
|
17
|
-
} = require("./src/commands/generate-templates/configuration");
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const packageJson = require("./package.json");
|
|
18
13
|
|
|
19
14
|
const codeGenBaseConfig = new CodeGenConfig({});
|
|
20
15
|
const templateGenBaseConfig = new TemplatesGenConfig({});
|
|
21
16
|
|
|
22
17
|
const program = cli({
|
|
23
|
-
name: name,
|
|
18
|
+
name: packageJson.name,
|
|
24
19
|
alias: "sta",
|
|
25
|
-
version: version,
|
|
20
|
+
version: packageJson.version,
|
|
26
21
|
description:
|
|
27
22
|
"Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.",
|
|
28
23
|
options: [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-typescript-api",
|
|
3
|
-
"version": "13.0.
|
|
4
|
-
"description": "Generate
|
|
3
|
+
"version": "13.0.9",
|
|
4
|
+
"description": "Generate the API client for Fetch or Axios from an OpenAPI Specification",
|
|
5
5
|
"homepage": "https://github.com/acacode/swagger-typescript-api",
|
|
6
6
|
"bugs": "https://github.com/acacode/swagger-typescript-api/issues",
|
|
7
7
|
"repository": "github:acacode/swagger-typescript-api",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"contributors": [
|
|
11
11
|
"Sora Morimoto <sora@morimoto.io>"
|
|
12
12
|
],
|
|
13
|
+
"type": "module",
|
|
13
14
|
"main": "./src/index.js",
|
|
14
15
|
"types": "./index.d.ts",
|
|
15
16
|
"bin": {
|
|
@@ -46,17 +47,22 @@
|
|
|
46
47
|
"prettier": "~3.3.2",
|
|
47
48
|
"swagger-schema-official": "2.0.0-bab6bed",
|
|
48
49
|
"swagger2openapi": "^7.0.8",
|
|
49
|
-
"typescript": "~5.
|
|
50
|
+
"typescript": "~5.5.2"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@biomejs/biome": "1.8.
|
|
53
|
+
"@biomejs/biome": "1.8.2",
|
|
54
|
+
"@tsconfig/node18": "18.2.4",
|
|
55
|
+
"@tsconfig/strictest": "2.0.5",
|
|
56
|
+
"@types/didyoumean": "1.2.2",
|
|
57
|
+
"@types/js-yaml": "4.0.9",
|
|
53
58
|
"@types/lodash": "4.17.5",
|
|
54
|
-
"@types/node": "20.14.
|
|
59
|
+
"@types/node": "20.14.8",
|
|
60
|
+
"@types/swagger2openapi": "7.0.4",
|
|
55
61
|
"axios": "1.7.2",
|
|
56
62
|
"shx": "0.3.4",
|
|
57
63
|
"vitest": "1.6.0"
|
|
58
64
|
},
|
|
59
|
-
"packageManager": "yarn@4.3.
|
|
65
|
+
"packageManager": "yarn@4.3.1",
|
|
60
66
|
"engines": {
|
|
61
67
|
"node": ">=18.0.0"
|
|
62
68
|
},
|
package/src/code-formatter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import prettier from "prettier";
|
|
3
|
+
import ts from "typescript";
|
|
4
4
|
|
|
5
5
|
class CodeFormatter {
|
|
6
6
|
/**
|
|
@@ -23,7 +23,7 @@ class CodeFormatter {
|
|
|
23
23
|
{ newLineCharacter: ts.sys.newLine },
|
|
24
24
|
)[0];
|
|
25
25
|
|
|
26
|
-
if (fileTextChanges
|
|
26
|
+
if (fileTextChanges?.textChanges.length) {
|
|
27
27
|
return _.reduceRight(
|
|
28
28
|
fileTextChanges.textChanges,
|
|
29
29
|
(content, { span, newText }) =>
|
|
@@ -111,6 +111,4 @@ class TsLanguageServiceHost {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
CodeFormatter,
|
|
116
|
-
};
|
|
114
|
+
export { CodeFormatter };
|
package/src/code-gen-process.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { CodeFormatter } from "./code-formatter.js";
|
|
4
|
+
import { CodeGenConfig } from "./configuration.js";
|
|
5
|
+
import { SchemaComponentsMap } from "./schema-components-map.js";
|
|
6
|
+
import { SchemaParserFabric } from "./schema-parser/schema-parser-fabric.js";
|
|
7
|
+
import { SchemaRoutes } from "./schema-routes/schema-routes.js";
|
|
8
|
+
import { SchemaWalker } from "./schema-walker.js";
|
|
9
|
+
import { SwaggerSchemaResolver } from "./swagger-schema-resolver.js";
|
|
10
|
+
import { TemplatesWorker } from "./templates-worker.js";
|
|
11
|
+
import { JavascriptTranslator } from "./translators/javascript.js";
|
|
12
|
+
import { TypeNameFormatter } from "./type-name-formatter.js";
|
|
13
|
+
import { FileSystem } from "./util/file-system.js";
|
|
14
|
+
import { internalCase } from "./util/internal-case.js";
|
|
15
|
+
import { Logger } from "./util/logger.js";
|
|
16
|
+
import { NameResolver } from "./util/name-resolver.js";
|
|
17
|
+
import { pascalCase } from "./util/pascal-case.js";
|
|
18
|
+
import { sortByProperty } from "./util/sort-by-property.js";
|
|
19
19
|
|
|
20
20
|
const PATCHABLE_INSTANCES = [
|
|
21
21
|
"schemaWalker",
|
|
@@ -533,7 +533,7 @@ class CodeGenProcess {
|
|
|
533
533
|
|
|
534
534
|
createApiConfig = (swaggerSchema) => {
|
|
535
535
|
const { info, servers, host, basePath, externalDocs, tags } = swaggerSchema;
|
|
536
|
-
const server =
|
|
536
|
+
const server = servers?.[0] || { url: "" };
|
|
537
537
|
const { title = "No title", version } = info || {};
|
|
538
538
|
const { url: serverUrl } = server;
|
|
539
539
|
|
|
@@ -566,6 +566,4 @@ class CodeGenProcess {
|
|
|
566
566
|
};
|
|
567
567
|
}
|
|
568
568
|
|
|
569
|
-
|
|
570
|
-
CodeGenProcess,
|
|
571
|
-
};
|
|
569
|
+
export { CodeGenProcess };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { HTTP_CLIENT, PROJECT_VERSION } from "../../constants.js";
|
|
2
|
+
import { objectAssign } from "../../util/object-assign.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @type {GenerateTemplatesParams}}
|
|
@@ -28,6 +28,4 @@ class TemplatesGenConfig {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
TemplatesGenConfig,
|
|
33
|
-
};
|
|
31
|
+
export { TemplatesGenConfig };
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// Node module: swagger-typescript-api
|
|
5
|
-
// This file is licensed under the MIT License.
|
|
6
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
7
|
-
// Repository https://github.com/acacode/swagger-typescript-api
|
|
3
|
+
import { TemplatesGenProcess } from "./templates-gen-process.js";
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
async function generateTemplates(config) {
|
|
6
|
+
const codeGenProcess = new TemplatesGenProcess(config);
|
|
7
|
+
return await codeGenProcess.start();
|
|
8
|
+
}
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
generateTemplates: async (config) => {
|
|
13
|
-
const codeGenProcess = new TemplatesGenProcess(config);
|
|
14
|
-
return await codeGenProcess.start();
|
|
15
|
-
},
|
|
16
|
-
};
|
|
10
|
+
export { generateTemplates };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import url from "node:url";
|
|
3
|
+
import { FileSystem } from "../../util/file-system.js";
|
|
4
|
+
import { Logger } from "../../util/logger.js";
|
|
5
|
+
import { TemplatesGenConfig } from "./configuration.js";
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
5
8
|
|
|
6
9
|
class TemplatesGenProcess {
|
|
7
10
|
/**
|
|
@@ -199,6 +202,4 @@ class TemplatesGenProcess {
|
|
|
199
202
|
};
|
|
200
203
|
}
|
|
201
204
|
|
|
202
|
-
|
|
203
|
-
TemplatesGenProcess,
|
|
204
|
-
};
|
|
205
|
+
export { TemplatesGenProcess };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { NameResolver } from "./util/name-resolver.js";
|
|
2
|
+
import { getRandomInt } from "./util/random.js";
|
|
3
3
|
|
|
4
4
|
class ComponentTypeNameResolver extends NameResolver {
|
|
5
5
|
counter = 1;
|
|
@@ -39,6 +39,4 @@ class ComponentTypeNameResolver extends NameResolver {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
ComponentTypeNameResolver,
|
|
44
|
-
};
|
|
42
|
+
export { ComponentTypeNameResolver };
|
package/src/configuration.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ts = require("typescript");
|
|
1
|
+
import { cosmiconfigSync } from "cosmiconfig";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { ComponentTypeNameResolver } from "./component-type-name-resolver.js";
|
|
5
|
+
import * as CONSTANTS from "./constants.js";
|
|
6
|
+
import { objectAssign } from "./util/object-assign.js";
|
|
8
7
|
|
|
9
8
|
const TsKeyword = {
|
|
10
9
|
Number: "number",
|
|
@@ -198,7 +197,7 @@ class CodeGenConfig {
|
|
|
198
197
|
};
|
|
199
198
|
|
|
200
199
|
compilerTsConfig = {
|
|
201
|
-
module:
|
|
200
|
+
module: ts.ModuleKind.ESNext,
|
|
202
201
|
noImplicitReturns: true,
|
|
203
202
|
alwaysStrict: true,
|
|
204
203
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -443,6 +442,4 @@ const getDefaultPrettierOptions = () => {
|
|
|
443
442
|
return { ...CONSTANTS.PRETTIER_OPTIONS };
|
|
444
443
|
};
|
|
445
444
|
|
|
446
|
-
|
|
447
|
-
CodeGenConfig,
|
|
448
|
-
};
|
|
445
|
+
export { CodeGenConfig };
|
package/src/constants.js
CHANGED
|
@@ -1,14 +1,51 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
1
4
|
const packageJson = require("../package.json");
|
|
2
|
-
|
|
5
|
+
|
|
6
|
+
const DEFAULT_BODY_ARG_NAME = "data";
|
|
7
|
+
|
|
8
|
+
const FILE_PREFIX = `/* eslint-disable */
|
|
9
|
+
/* tslint:disable */
|
|
10
|
+
/*
|
|
11
|
+
* ---------------------------------------------------------------
|
|
12
|
+
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
|
13
|
+
* ## ##
|
|
14
|
+
* ## AUTHOR: acacode ##
|
|
15
|
+
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
|
|
16
|
+
* ---------------------------------------------------------------
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const HTTP_CLIENT = {
|
|
22
|
+
FETCH: "fetch",
|
|
23
|
+
AXIOS: "axios",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const PRETTIER_OPTIONS = {
|
|
27
|
+
printWidth: 120,
|
|
28
|
+
tabWidth: 2,
|
|
29
|
+
trailingComma: "all",
|
|
30
|
+
parser: "typescript",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const PROJECT_VERSION = packageJson.version;
|
|
34
|
+
|
|
3
35
|
const RESERVED_BODY_ARG_NAMES = ["data", "body", "reqBody"];
|
|
36
|
+
|
|
37
|
+
const RESERVED_HEADER_ARG_NAMES = ["headers", "headersParams"];
|
|
38
|
+
|
|
39
|
+
const RESERVED_PATH_ARG_NAMES = ["path", "pathParams"];
|
|
40
|
+
|
|
41
|
+
const RESERVED_QUERY_ARG_NAMES = ["query", "queryParams", "queryArg"];
|
|
42
|
+
|
|
4
43
|
const RESERVED_REQ_PARAMS_ARG_NAMES = [
|
|
5
44
|
"params",
|
|
6
45
|
"requestParams",
|
|
7
46
|
"reqParams",
|
|
8
47
|
"httpParams",
|
|
9
48
|
];
|
|
10
|
-
const RESERVED_PATH_ARG_NAMES = ["path", "pathParams"];
|
|
11
|
-
const RESERVED_HEADER_ARG_NAMES = ["headers", "headersParams"];
|
|
12
49
|
|
|
13
50
|
const SCHEMA_TYPES = {
|
|
14
51
|
ARRAY: "array",
|
|
@@ -25,41 +62,16 @@ const SCHEMA_TYPES = {
|
|
|
25
62
|
COMPLEX_UNKNOWN: "__unknown",
|
|
26
63
|
};
|
|
27
64
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
AXIOS: "axios",
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const PROJECT_VERSION = packageJson.version;
|
|
34
|
-
|
|
35
|
-
const FILE_PREFIX = `/* eslint-disable */
|
|
36
|
-
/* tslint:disable */
|
|
37
|
-
/*
|
|
38
|
-
* ---------------------------------------------------------------
|
|
39
|
-
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
|
40
|
-
* ## ##
|
|
41
|
-
* ## AUTHOR: acacode ##
|
|
42
|
-
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
|
|
43
|
-
* ---------------------------------------------------------------
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
module.exports = {
|
|
65
|
+
export {
|
|
66
|
+
DEFAULT_BODY_ARG_NAME,
|
|
49
67
|
FILE_PREFIX,
|
|
50
|
-
DEFAULT_BODY_ARG_NAME: "data",
|
|
51
|
-
PROJECT_VERSION,
|
|
52
|
-
SCHEMA_TYPES,
|
|
53
68
|
HTTP_CLIENT,
|
|
54
|
-
|
|
69
|
+
PRETTIER_OPTIONS,
|
|
70
|
+
PROJECT_VERSION,
|
|
55
71
|
RESERVED_BODY_ARG_NAMES,
|
|
56
|
-
RESERVED_REQ_PARAMS_ARG_NAMES,
|
|
57
|
-
RESERVED_PATH_ARG_NAMES,
|
|
58
72
|
RESERVED_HEADER_ARG_NAMES,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
parser: "typescript",
|
|
64
|
-
},
|
|
73
|
+
RESERVED_PATH_ARG_NAMES,
|
|
74
|
+
RESERVED_QUERY_ARG_NAMES,
|
|
75
|
+
RESERVED_REQ_PARAMS_ARG_NAMES,
|
|
76
|
+
SCHEMA_TYPES,
|
|
65
77
|
};
|
package/src/index.js
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
7
|
-
// Repository https://github.com/acacode/swagger-typescript-api
|
|
3
|
+
import { CodeGenProcess } from "./code-gen-process.js";
|
|
4
|
+
import { generateTemplates } from "./commands/generate-templates/index.js";
|
|
5
|
+
import * as constants from "./constants.js";
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
7
|
+
async function generateApi({ name, prettier, ...config }) {
|
|
8
|
+
const codeGenProcess = new CodeGenProcess({
|
|
9
|
+
...config,
|
|
10
|
+
fileName: name,
|
|
11
|
+
prettierOptions: prettier,
|
|
12
|
+
});
|
|
13
|
+
return await codeGenProcess.start();
|
|
14
|
+
}
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
constants: constants,
|
|
15
|
-
generateApi: async ({ name, prettier, ...config }) => {
|
|
16
|
-
const codeGenProcess = new CodeGenProcess({
|
|
17
|
-
...config,
|
|
18
|
-
fileName: name,
|
|
19
|
-
prettierOptions: prettier,
|
|
20
|
-
});
|
|
21
|
-
return await codeGenProcess.start();
|
|
22
|
-
},
|
|
23
|
-
generateTemplates: async (config) => {
|
|
24
|
-
return await generateTemplates(config);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
16
|
+
export { constants, generateApi, generateTemplates };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
2
|
|
|
3
3
|
class SchemaComponentsMap {
|
|
4
4
|
/** @type {SchemaComponent[]} */
|
|
@@ -73,6 +73,4 @@ class SchemaComponentsMap {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
SchemaComponentsMap,
|
|
78
|
-
};
|
|
76
|
+
export { SchemaComponentsMap };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../../constants.js";
|
|
3
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
4
4
|
|
|
5
5
|
class ArraySchemaParser extends MonoSchemaParser {
|
|
6
6
|
parse() {
|
|
@@ -38,6 +38,4 @@ class ArraySchemaParser extends MonoSchemaParser {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
ArraySchemaParser,
|
|
43
|
-
};
|
|
41
|
+
export { ArraySchemaParser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../../constants.js";
|
|
3
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
4
4
|
|
|
5
5
|
class ComplexSchemaParser extends MonoSchemaParser {
|
|
6
6
|
parse() {
|
|
@@ -46,6 +46,4 @@ class ComplexSchemaParser extends MonoSchemaParser {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
ComplexSchemaParser,
|
|
51
|
-
};
|
|
49
|
+
export { ComplexSchemaParser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../../constants.js";
|
|
3
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
4
4
|
|
|
5
5
|
class DiscriminatorSchemaParser extends MonoSchemaParser {
|
|
6
6
|
parse() {
|
|
@@ -302,6 +302,4 @@ class DiscriminatorSchemaParser extends MonoSchemaParser {
|
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
|
|
306
|
-
DiscriminatorSchemaParser,
|
|
307
|
-
};
|
|
305
|
+
export { DiscriminatorSchemaParser };
|