Skip to content

Commit 9a55e7c

Browse files
authored
Merge pull request #458 from acacode/next
Release 13.0.0
2 parents ec190c9 + 2f7dee8 commit 9a55e7c

File tree

220 files changed

+62467
-5389
lines changed

Some content is hidden

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

220 files changed

+62467
-5389
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TEST_FILE_NAME=github-swagger.ts
2+
TEST_SCHEMA_VERSION=v3
3+
TEST_WITH_DEBUG=true

.prettierignore renamed to .eslintignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
.eslintrc
2+
node_modules
3+
.husky
4+
.vscode
5+
swagger-test-cli
6+
tests
7+
*.ejs
8+
*.eta
9+
.kube
10+
.idea
11+
*.json
12+
.eslintrc.js
13+
vite.config.ts
114
tests/**/*.ts
215
tests/**/schema.js
316
tests/**/schema.ts
@@ -7,7 +20,6 @@ swagger-test-cli.*
720
templates
821
*.md
922
.github
10-
node_modules
1123
.openapi-generator
1224
.vscode
1325
assets

.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
parserOptions: {
3+
"ecmaVersion": "latest"
4+
},
5+
env: {
6+
"node": true,
7+
"es6": true
8+
},
9+
extends: [
10+
'eslint:recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
plugins: [
14+
'prettier',
15+
],
16+
rules: {
17+
'prettier/prettier': [
18+
'error',
19+
{
20+
endOfLine: 'auto',
21+
printWidth: 80,
22+
tabWidth: 2,
23+
trailingComma: 'all',
24+
semi: true,
25+
singleQuote: true,
26+
},
27+
],
28+
},
29+
};

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
open-pull-requests-limit: 100
6+
schedule:
7+
interval: "daily"

.github/workflows/main.yml

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,94 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: Builds, tests & co
22

3-
name: Run tests
4-
5-
# Controls when the action will run.
63
on:
7-
# Triggers the workflow on push or pull request events but only for the master branch
8-
pull_request:
9-
branches: [ master, next ]
10-
11-
# Allows you to run this workflow manually from the Actions tab
12-
workflow_dispatch:
4+
- push
5+
- pull_request
136

14-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
157
jobs:
16-
# This workflow contains a single job called "build"
17-
build:
18-
# The type of runner that the job will run on
19-
runs-on: ubuntu-latest
8+
build-and-test:
209
strategy:
10+
fail-fast: false
2111
matrix:
22-
node-version: [11.x, 13.x, 15.x]
12+
os:
13+
- macos-latest
14+
- ubuntu-latest
15+
- windows-latest
16+
node-version:
17+
- 16.x
18+
- 18.x
2319

24-
name: Node.js (test-all) ${{ matrix.node-version }}
20+
runs-on: ${{ matrix.os }}
2521

26-
# Steps represent a sequence of tasks that will be executed as part of the job
2722
steps:
28-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29-
- uses: actions/checkout@v2
23+
- name: Checkout tree
24+
uses: actions/checkout@v3
25+
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
31+
- name: Install npm packages
32+
run: npm ci --ignore-scripts
33+
34+
- name: Run the tests
35+
run: npm run test-all
36+
37+
dependabot-auto-approve:
38+
name: Dependabot auto-approve
39+
40+
permissions:
41+
pull-requests: write
42+
43+
needs:
44+
- build-and-test
45+
46+
if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}
47+
48+
runs-on: ubuntu-latest
3049

31-
# Runs a single command using the runners shell
32-
- name: install deps
33-
run: npm i
50+
steps:
51+
- name: Fetch Dependabot metadata
52+
id: metadata
53+
uses: dependabot/fetch-metadata@v1
54+
55+
- name: Get the PR review decision
56+
id: gh-pr-review
57+
run: echo "decision=$(gh pr view --json reviewDecision --jq '. | .reviewDecision' "$PR_URL")" >>"$GITHUB_OUTPUT"
58+
env:
59+
PR_URL: ${{ github.event.pull_request.html_url }}
60+
GITHUB_TOKEN: ${{ github.token }}
61+
62+
- name: Approve a PR
63+
if: ${{ steps.gh-pr-review.outputs.decision != 'APPROVED' && steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
64+
run: gh pr review --approve "$PR_URL"
65+
env:
66+
PR_URL: ${{ github.event.pull_request.html_url }}
67+
GITHUB_TOKEN: ${{ github.token }}
68+
69+
dependabot-auto-merge:
70+
name: Dependabot auto-merge
71+
72+
permissions:
73+
contents: write
74+
pull-requests: write
75+
76+
if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}
77+
78+
needs:
79+
- build-and-test
80+
- dependabot-auto-approve
81+
82+
runs-on: ubuntu-latest
83+
84+
steps:
85+
- name: Fetch Dependabot metadata
86+
id: metadata
87+
uses: dependabot/fetch-metadata@v1
3488

35-
# Runs a set of commands using the runners shell
36-
- name: test
37-
run: npm run test-all-extended
89+
- name: Merge Dependabot PR
90+
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
91+
run: gh pr merge --auto --merge "$PR_URL"
92+
env:
93+
PR_URL: ${{ github.event.pull_request.html_url }}
94+
GITHUB_TOKEN: ${{ github.token }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ node_modules
33
.idea
44
swagger-test-cli.*
55
swagger-test-cli
6-
dist
6+
dist
7+
.env

.husky/post-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
git update-index -g

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run lint:fix

.ncurc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"upgrade": true,
3+
"reject": [
4+
"nanoid",
5+
"eta"
6+
]
7+
}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.16.0
1+
18.16.1

.prettierrc

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

.vscode/launch.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"name": "Debug generate",
9-
"type": "node",
10-
"request": "launch",
11-
"cwd": "${workspaceFolder}",
12-
"runtimeExecutable": "npm",
13-
"runtimeArgs": ["run-script", "generate:debug"]
14-
},
157
{
168
"name": "Debug JSON CLI",
179
"type": "node",
@@ -60,14 +52,6 @@
6052
"runtimeExecutable": "npm",
6153
"runtimeArgs": ["run-script", "test-all"]
6254
},
63-
{
64-
"name": "Debug test-all-extended",
65-
"type": "node",
66-
"request": "launch",
67-
"cwd": "${workspaceFolder}",
68-
"runtimeExecutable": "npm",
69-
"runtimeArgs": ["run-script", "test-all-extended"]
70-
},
7155
{
7256
"name": "Debug test:--extract-request-body",
7357
"type": "node",

CHANGELOG.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
# next release
22

3+
BREAKING_CHANGE: disable support NodeJS 14.x
4+
BREAKING_CHANGE: change swagger-typescript-api NodeJS "generateApi" function return type
5+
BREAKING_CHANGE: remove `rawModelTypes` from output api configuration
6+
feat: `--custom-config <string>` option (#503)
7+
feat: `--sort-routes` option, ability to sort routes;
8+
fix: critical bugs based with extract types and enums
9+
fix: sort types option (sort was not correctly work with nested or extracted types)
10+
fix: problems based with extracting enums;
11+
fix: nullable enum with integer values (#543)
12+
fix: generation enum numbers as strings one (#534)
13+
chore: refactoring the axios imports
14+
fix: non-object custom spec extensions (#500)
15+
fix(docs): input instead of output in readme
16+
internal: remove redundant internal scripts
17+
internal: change process with using custom templates
18+
19+
```diff
20+
interface GenerateApiOutput {
21+
...
22+
- files: { name: string; content: string; declaration: { name: string; content: string } | null }[];
23+
+ files: { fileName: string; fileContent: string; fileExtension: string }[];
24+
...
25+
}
26+
```
27+
28+
internal: refactor schema parser code (preparing it for async code execution)
29+
fix: problem with filtering primitive in complex types (#459)
30+
feat: add discriminator property support (#456)
31+
internal: prepare code + templates for async code execution (next plans)
32+
fix: problems with dot in query params (hard fix) (#460)
33+
feature: ability to send custom Ts output code translator to js. Example:
34+
```ts
35+
const { Translator } = require("swagger-typescript-api/src/translators/translator");
36+
const { JavascriptTranslator } = require("swagger-typescript-api/src/translators/javascript");
37+
38+
class MyTranslator extends Translator { // or use extends JavascriptTranslator
39+
translate({ fileName, fileExtension, fileContent }) {
40+
// format ts\js code with using this codeFormatter (prettier + ts import fixer)
41+
this.codeFormatter.format(fileContent)
42+
// config of the code gen process
43+
this.config.
44+
// logger
45+
this.logger.
46+
47+
return [
48+
{
49+
fileName,
50+
fileExtension,
51+
fileContent,
52+
}
53+
]
54+
}
55+
}
56+
```
57+
358
## 12.0.4
459

560
fix: onCreateRoute skip behaviour
@@ -484,7 +539,7 @@ Features:
484539
name?: string;
485540
path?: string;
486541
}) => string
487-
formatTSContent: (content: string) => string;
542+
formatTSContent: (content: string) => Promise<string>;
488543

489544

490545
// ...

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const { generateApi, generateTemplates } = require('swagger-typescript-api');
106106
const path = require("path");
107107
const fs = require("fs");
108108

109-
/* NOTE: all fields are optional expect one of `output`, `url`, `spec` */
109+
/* NOTE: all fields are optional expect one of `input`, `url`, `spec` */
110110
generateApi({
111111
name: "MySuperbApi.ts",
112112
// set to `false` to prevent the tool from writing to disk

cli/constants.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const root_command = Symbol("root");
2-
const skip_command = Symbol("skip");
1+
const root_command = Symbol('root');
2+
const skip_command = Symbol('skip');
33

4-
const reservedOptions = ["version", "help"];
4+
const reservedOptions = ['version', 'help'];
55

66
module.exports = {
77
root_command,

0 commit comments

Comments
 (0)