Skip to content

Commit cc26e60

Browse files
authored
Merge branch 'acacode:main' into main
2 parents b31b940 + cdc26d0 commit cc26e60

File tree

423 files changed

+118672
-189483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

423 files changed

+118672
-189483
lines changed

.env.example

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/FUNDING.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
ko_fi: js2me
21
custom: ["https://paypal.me/acacode"]
2+
github: smorimoto
3+
ko_fi: js2me

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ on:
44
- push
55
- pull_request
66

7+
permissions: read-all
8+
79
jobs:
810
build-and-test:
911
runs-on: ubuntu-latest
10-
1112
steps:
1213
- name: Checkout tree
1314
uses: actions/checkout@v4
@@ -25,4 +26,4 @@ jobs:
2526
run: yarn format:check
2627

2728
- name: Run the tests
28-
run: yarn test-all
29+
run: yarn test

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
permissions: read-all
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout tree
15+
uses: actions/checkout@v4
16+
17+
- name: Set-up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
check-latest: true
22+
23+
- name: Publish
24+
run: yarn npm publish --tolerate-republish
25+
env:
26+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.gitignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
/.yarn/*
22
!/.yarn/releases
3-
4-
/.idea/
5-
/.vscode/
6-
/dist/
73
/node_modules/
8-
9-
.env
10-
swagger-test-cli
11-
swagger-test-cli.*

.yarn/releases/yarn-4.2.2.cjs renamed to .yarn/releases/yarn-4.3.1.cjs

Lines changed: 313 additions & 313 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
defaultSemverRangePrefix: ""
2+
13
nodeLinker: node-modules
24

5+
npmRegistries:
6+
//registry.npmjs.org:
7+
npmAuthToken: "${NPM_AUTH_TOKEN:-''}"
8+
39
preferInteractive: true
410

5-
yarnPath: .yarn/releases/yarn-4.2.2.cjs
11+
yarnPath: .yarn/releases/yarn-4.3.1.cjs

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1919
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
2020
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2121
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
11
# swagger-typescript-api
22

3-
<img
4-
src="https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/swagger-typescript-api-logo.png"
5-
title="swagger-typescript-api logo by js2me"
6-
align="left"
7-
height="180"
8-
width="93"
9-
/>
3+
- Support for OpenAPI 3.0, 2.0, JSON and YAML
4+
- Generate the API Client for Fetch or Axios from an OpenAPI Specification
105

11-
- Generate api via swagger scheme
12-
- Supports OA 3.0, 2.0, JSON, yaml
13-
- Generated api module use [**Fetch Api**](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) or [**Axios**](https://github.com/axios/axios) to make requests.
6+
Any questions you can ask [**here**](https://github.com/acacode/swagger-typescript-api/discussions)
147

15-
<br>
8+
## Examples
169

17-
Any questions you can ask [**here**](https://github.com/acacode/swagger-typescript-api/issues) or in [**our Slack**](https://join.slack.com/t/acacode/shared_invite/enQtOTQ5ODgyODQzMzYwLWYxOGI1MzQ3Yzg1ZWI5ZTI5NzNiZjExZTE5OWI1YjQ4NjBiNTk4NWVlNjM5YmU1ZWI2ZDkyMzZkZGIxNjA5NTQ)(**#swagger-typescript-api** channel)
10+
All examples you can find [**here**](https://github.com/acacode/swagger-typescript-api/tree/main/tests)
1811

19-
![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/components-converter-example.jpg)
20-
21-
Thanks to [JetBrains](https://www.jetbrains.com/?from=swaggertypescriptapi) for providing a free license for their excellent Webstorm IDE.
22-
23-
## 👀 Examples
24-
25-
All examples you can find [**here**](https://github.com/acacode/swagger-typescript-api/tree/master/tests)
26-
27-
## 📄 Usage
12+
## Usage
2813

2914
```muse
3015
Usage: sta [options]
@@ -203,7 +188,7 @@ generateTemplates({
203188
});
204189
```
205190

206-
## 💎 options
191+
## Options
207192

208193
### **`--templates`**
209194

@@ -487,21 +472,13 @@ generateApi({
487472

488473
See more about [swagger schema type/format data here](https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times)
489474

490-
## 📄 Mass media
475+
## Mass media
491476

492477
- [5 Lessons learned about swagger-typescript-api](https://christo8989.medium.com/5-lessons-learned-about-swagger-typescript-api-511240b34c1)
493478
- [Why Swagger schemes are needed in frontend development ?](https://dev.to/js2me/why-swagger-schemes-are-needed-in-frontend-development-2cb4)
494479
- [Migration en douceur vers TypeScript (French)](https://www.premieroctet.com/blog/migration-typescript/)
495480
- [swagger-typescript-api usage (Japanese)](https://zenn.dev/watahaya/articles/2f4a716c47903b)
496481

497-
## 🚀 How it looks
498-
499-
![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/npx.gif)
500-
501-
![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/auth-example.gif)
502-
503-
![](https://raw.githubusercontent.com/acacode/swagger-typescript-api/master/assets/typings1.gif)
504-
505-
## 📝 License
482+
## License
506483

507-
Licensed under the [MIT License](https://github.com/acacode/swagger-typescript-api/blob/master/LICENSE).
484+
Licensed under the [MIT License](https://github.com/acacode/swagger-typescript-api/blob/main/LICENSE).

assets/auth-example.gif

-4.8 MB
Binary file not shown.
-63.8 KB
Binary file not shown.

assets/npx.gif

-319 KB
Binary file not shown.
-13.9 KB
Binary file not shown.

assets/typings1.gif

-3.71 MB
Binary file not shown.

biome.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
{
22
"$schema": "node_modules/@biomejs/biome/configuration_schema.json",
33
"files": {
4-
"ignore": [
5-
"package.json",
6-
"tests/**/expected.ts",
7-
"tests/**/expected/**",
8-
"tests/**/generated/**",
9-
"tests/**/schema.d.ts",
10-
"tests/**/schema.js",
11-
"tests/**/schema.ts"
12-
],
4+
"ignore": ["package.json"],
135
"maxSize": 10000000
146
},
157
"formatter": {

cli/constants.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ const skip_command = Symbol("skip");
33

44
const reservedOptions = ["version", "help"];
55

6-
module.exports = {
7-
root_command,
8-
skip_command,
9-
reservedOptions,
10-
};
6+
export { root_command, skip_command, reservedOptions };

cli/execute.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const _ = require("lodash");
2-
const { root_command, skip_command } = require("./constants");
3-
const { parseArgs } = require("./parse-args");
4-
const didYouMean = require("didyoumean");
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";
55

66
didYouMean.threshold = 0.5;
77

@@ -177,6 +177,4 @@ const processArgs = (commands, args) => {
177177
};
178178
};
179179

180-
module.exports = {
181-
execute,
182-
};
180+
export { execute };

cli/index.d.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
type CliStructOption = {
2-
flags?: string;
3-
description?: string;
42
default?: unknown;
3+
description?: string;
4+
flags?: string;
55
internal?: { name?: string; formatter?: (value: any) => any };
6+
required?: boolean;
67
};
78

89
type CliStruct = {
9-
inherited?: string | null;
10-
name?: string;
1110
alias?: string;
12-
version?: string;
11+
commands?: CliStruct[];
1312
description?: string;
13+
inherited?: string | null;
14+
name?: string;
1415
options: CliStructOption[];
15-
commands?: CliStruct[];
16+
version?: string;
1617
};
1718

1819
type ExecuteOptions = {

cli/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const _ = require("lodash");
2-
const { reservedOptions, root_command } = require("./constants");
3-
const { processOption } = require("./process-option");
4-
const { execute } = require("./execute");
5-
const { displayHelp } = require("./operations/display-help");
6-
const { displayVersion } = require("./operations/display-version");
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";
77

88
const cli = (input) => {
99
const commands = {};
@@ -91,6 +91,4 @@ const cli = (input) => {
9191
return instance;
9292
};
9393

94-
module.exports = {
95-
cli,
96-
};
94+
export { cli };

cli/operations/display-help.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const _ = require("lodash");
2-
const { root_command } = require("../constants");
1+
import _ from "lodash";
2+
import { root_command } from "../constants.js";
33

44
const generateOptionsOutput = (options) =>
55
options.reduce(
@@ -174,6 +174,4 @@ ${command.description}`
174174
${outputTest}`);
175175
};
176176

177-
module.exports = {
178-
displayHelp,
179-
};
177+
export { displayHelp };

cli/operations/display-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ const displayVersion = (instance) => {
22
console.log(instance.input.version);
33
};
44

5-
module.exports = { displayVersion };
5+
export { displayVersion };

cli/parse-args.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ const parseArgs = (args, type) => {
2121
}
2222
};
2323

24-
module.exports = {
25-
parseArgs,
26-
};
24+
export { parseArgs };

cli/process-option.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const _ = require("lodash");
1+
import _ from "lodash";
22

33
const optionFormatters = {
44
number: (str) => +str,
@@ -72,6 +72,4 @@ const processOption = (option) => {
7272
};
7373
};
7474

75-
module.exports = {
76-
processOption,
77-
};
75+
export { processOption };

index.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
#!/usr/bin/env node
22

3-
// Copyright (c) 2019-present acacode
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 { 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";
810

9-
const { version, name } = require("./package.json");
10-
const { cli } = require("./cli");
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");
1813

1914
const codeGenBaseConfig = new CodeGenConfig({});
2015
const templateGenBaseConfig = new TemplatesGenConfig({});
2116

2217
const program = cli({
23-
name: name,
18+
name: packageJson.name,
2419
alias: "sta",
25-
version: version,
20+
version: packageJson.version,
2621
description:
2722
"Generate api via swagger scheme.\nSupports OA 3.0, 2.0, JSON, yaml.",
2823
options: [

0 commit comments

Comments
 (0)