Skip to content

Release 13.0.0 #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d185c22
internal: optimize cli usage
js2me Nov 14, 2022
d5ee693
feat: discriminator mapping draft
js2me Nov 14, 2022
37e06c3
fix: problems with using name resolver due to extracting types
js2me Nov 15, 2022
3bf532c
fix: improve discriminator mapping usage
js2me Nov 15, 2022
72ab68c
feat: improve data-contracts ejs file (ability to add generic types f…
js2me Nov 15, 2022
4b6cd25
refactor: mono schema parsers
js2me Nov 16, 2022
5466dba
refactor: part array type own parser
js2me Nov 16, 2022
e052452
refactor: part array type own parser (2)
js2me Nov 16, 2022
3677844
fix: build after refactoring
js2me Nov 17, 2022
7dd1a86
refactor: add _ for schema parsers maps
js2me Nov 17, 2022
c5a204b
refactor: project source code
js2me Nov 18, 2022
4ad99d3
refactor: project source code, prepare it for future async operations
js2me Nov 18, 2022
0980e3e
feat: ability to send custom ts code translator;
js2me Nov 18, 2022
e340527
docs: update CHANGELOG
js2me Nov 18, 2022
9736cde
feat: enable discriminator
js2me Nov 18, 2022
ea5df29
docs: update CHANGELOG
js2me Nov 18, 2022
dd74bd4
docs: update CHANGELOG
js2me Nov 18, 2022
c9447ed
docs: update CHANGELOG
js2me Nov 18, 2022
68fb034
feat: discriminator and nested enums
js2me Nov 19, 2022
928025b
internal: remove redundant internal scripts
js2me Nov 21, 2022
fb20a04
internal: reorganize name-resolver util
js2me Nov 21, 2022
00d77f9
fix: problems based with extracting enums;
js2me Nov 28, 2022
ca5f42d
fix: onCreateRoute skip behaviour
Dec 25, 2022
7a60904
Update GitHub Actions workflow
smorimoto Feb 7, 2023
ced8e18
Rename test:sort-types(false) -> test:sort-types-false
smorimoto Feb 8, 2023
294e011
Enable Dependabot
smorimoto Feb 9, 2023
41cea41
Merge pull request #493 from acacode/update-gha
smorimoto Feb 9, 2023
bfc469c
update vulnerable deps
juliusBaranauskas Feb 1, 2023
5d86da4
Merge pull request #490 from juliusBaranauskas/fix_CVE-2022-25967
smorimoto Feb 9, 2023
70e6427
fix regex to match numbers in path parameters
koolmonke Feb 21, 2023
c3384d7
Update index.js
to-long Mar 12, 2023
d0bd85f
Update index.js
to-long Mar 12, 2023
0d64c7f
Update index.js
to-long Mar 12, 2023
f34702c
Supporting exactOptionalPropertyTypes
seivan Feb 28, 2023
b38cd83
Merge pull request #476 from ivanovart/next
js2me Mar 22, 2023
034492e
Merge remote-tracking branch 'origin/master' into next
js2me Mar 22, 2023
5425f9b
fix: merge conflicts from master
js2me Mar 23, 2023
253acf1
fix: input instead of output in readme
Mar 29, 2023
e4ff735
fix non-object custom spec extensions
ajmnz Mar 30, 2023
6e1d2d2
fix: Use type-only import for axios types
pataiadam Jun 15, 2023
716718b
Merge pull request #1 from pataiadam/pataiadam-patch-1
pataiadam Jun 15, 2023
5d86123
fic: Replace imports of Axios library
pataiadam Jun 16, 2023
51b3655
Merge pull request #541 from pataiadam/next
js2me Jul 12, 2023
54003a4
Merge pull request #515 from ajmnz/fix/custom-extensions
js2me Jul 12, 2023
ebd09b7
Merge pull request #514 from xueerli/fix-readme
js2me Jul 12, 2023
79c007d
Merge pull request #498 from seivan/patch-2
js2me Jul 12, 2023
b5307d1
Merge pull request #495 from koolmonkey/next
js2me Jul 12, 2023
84f9dae
BREAKING_CHANGE: update deps to latest;
js2me Jul 12, 2023
418e5cd
docs: update README
js2me Jul 13, 2023
56a8e1a
Merge branch 'next' into master
js2me Jul 13, 2023
9af7d5d
Merge pull request #504 from BrianTo176/master
js2me Jul 13, 2023
76e5920
docs: update CHANGELOG; chore: lint index.js
js2me Jul 13, 2023
39ca291
fix: nullable enum with integer values
js2me Jul 13, 2023
64c3be0
fix: generation enum numbers as strings one
js2me Jul 13, 2023
814b378
chore: remove 14.x node version
js2me Jul 13, 2023
2486200
docs: update CHANGELOG
js2me Jul 13, 2023
2f7dee8
bump: release 13.0.0
js2me Jul 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TEST_FILE_NAME=github-swagger.ts
TEST_SCHEMA_VERSION=v3
TEST_WITH_DEBUG=true
14 changes: 13 additions & 1 deletion .prettierignore → .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
.eslintrc
node_modules
.husky
.vscode
swagger-test-cli
tests
*.ejs
*.eta
.kube
.idea
*.json
.eslintrc.js
vite.config.ts
tests/**/*.ts
tests/**/schema.js
tests/**/schema.ts
Expand All @@ -7,7 +20,6 @@ swagger-test-cli.*
templates
*.md
.github
node_modules
.openapi-generator
.vscode
assets
Expand Down
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
parserOptions: {
"ecmaVersion": "latest"
},
env: {
"node": true,
"es6": true
},
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
],
plugins: [
'prettier',
],
rules: {
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
printWidth: 80,
tabWidth: 2,
trailingComma: 'all',
semi: true,
singleQuote: true,
},
],
},
};
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
open-pull-requests-limit: 100
schedule:
interval: "daily"
109 changes: 83 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,94 @@
# This is a basic workflow to help you get started with Actions
name: Builds, tests & co

name: Run tests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
pull_request:
branches: [ master, next ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
- push
- pull_request

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

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

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Checkout tree
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install npm packages
run: npm ci --ignore-scripts

- name: Run the tests
run: npm run test-all

dependabot-auto-approve:
name: Dependabot auto-approve

permissions:
pull-requests: write

needs:
- build-and-test

if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}

runs-on: ubuntu-latest

# Runs a single command using the runners shell
- name: install deps
run: npm i
steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1

- name: Get the PR review decision
id: gh-pr-review
run: echo "decision=$(gh pr view --json reviewDecision --jq '. | .reviewDecision' "$PR_URL")" >>"$GITHUB_OUTPUT"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ github.token }}

- name: Approve a PR
if: ${{ steps.gh-pr-review.outputs.decision != 'APPROVED' && steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ github.token }}

dependabot-auto-merge:
name: Dependabot auto-merge

permissions:
contents: write
pull-requests: write

if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}

needs:
- build-and-test
- dependabot-auto-approve

runs-on: ubuntu-latest

steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1

# Runs a set of commands using the runners shell
- name: test
run: npm run test-all-extended
- name: Merge Dependabot PR
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ github.token }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
.idea
swagger-test-cli.*
swagger-test-cli
dist
dist
.env
4 changes: 4 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

git update-index -g
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run lint:fix
7 changes: 7 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"upgrade": true,
"reject": [
"nanoid",
"eta"
]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.16.0
18.16.1
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

16 changes: 0 additions & 16 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug generate",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": ["run-script", "generate:debug"]
},
{
"name": "Debug JSON CLI",
"type": "node",
Expand Down Expand Up @@ -60,14 +52,6 @@
"runtimeExecutable": "npm",
"runtimeArgs": ["run-script", "test-all"]
},
{
"name": "Debug test-all-extended",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": ["run-script", "test-all-extended"]
},
{
"name": "Debug test:--extract-request-body",
"type": "node",
Expand Down
57 changes: 56 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
# next release

BREAKING_CHANGE: disable support NodeJS 14.x
BREAKING_CHANGE: change swagger-typescript-api NodeJS "generateApi" function return type
BREAKING_CHANGE: remove `rawModelTypes` from output api configuration
feat: `--custom-config <string>` option (#503)
feat: `--sort-routes` option, ability to sort routes;
fix: critical bugs based with extract types and enums
fix: sort types option (sort was not correctly work with nested or extracted types)
fix: problems based with extracting enums;
fix: nullable enum with integer values (#543)
fix: generation enum numbers as strings one (#534)
chore: refactoring the axios imports
fix: non-object custom spec extensions (#500)
fix(docs): input instead of output in readme
internal: remove redundant internal scripts
internal: change process with using custom templates

```diff
interface GenerateApiOutput {
...
- files: { name: string; content: string; declaration: { name: string; content: string } | null }[];
+ files: { fileName: string; fileContent: string; fileExtension: string }[];
...
}
```

internal: refactor schema parser code (preparing it for async code execution)
fix: problem with filtering primitive in complex types (#459)
feat: add discriminator property support (#456)
internal: prepare code + templates for async code execution (next plans)
fix: problems with dot in query params (hard fix) (#460)
feature: ability to send custom Ts output code translator to js. Example:
```ts
const { Translator } = require("swagger-typescript-api/src/translators/translator");
const { JavascriptTranslator } = require("swagger-typescript-api/src/translators/javascript");

class MyTranslator extends Translator { // or use extends JavascriptTranslator
translate({ fileName, fileExtension, fileContent }) {
// format ts\js code with using this codeFormatter (prettier + ts import fixer)
this.codeFormatter.format(fileContent)
// config of the code gen process
this.config.
// logger
this.logger.

return [
{
fileName,
fileExtension,
fileContent,
}
]
}
}
```

## 12.0.4

fix: onCreateRoute skip behaviour
Expand Down Expand Up @@ -484,7 +539,7 @@ Features:
name?: string;
path?: string;
}) => string
formatTSContent: (content: string) => string;
formatTSContent: (content: string) => Promise<string>;


// ...
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const { generateApi, generateTemplates } = require('swagger-typescript-api');
const path = require("path");
const fs = require("fs");

/* NOTE: all fields are optional expect one of `output`, `url`, `spec` */
/* NOTE: all fields are optional expect one of `input`, `url`, `spec` */
generateApi({
name: "MySuperbApi.ts",
// set to `false` to prevent the tool from writing to disk
Expand Down
6 changes: 3 additions & 3 deletions cli/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const root_command = Symbol("root");
const skip_command = Symbol("skip");
const root_command = Symbol('root');
const skip_command = Symbol('skip');

const reservedOptions = ["version", "help"];
const reservedOptions = ['version', 'help'];

module.exports = {
root_command,
Expand Down
Loading