Skip to content
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

Provide support for OpenAPI 3.1.0 #2786

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
ace708a
chore: integrate ApiDOM into codebase
char0n Dec 27, 2022
0ce91cc
feat(resolve): add ApiDOM JSON parser (#2739)
char0n Dec 27, 2022
57be33a
chore(deps): fix missing dependencies
char0n Dec 27, 2022
f9f9222
feat(resolve): add ApiDOM YAML 1.2 parser
char0n Dec 27, 2022
f231a61
feat(resolve): add ApiDOM OpenAPI 3.1.0 JSON parser
char0n Dec 27, 2022
48340c6
feat(resolve): add ApiDOM OpenAPI 3.1.0 YAML 1.2 parser
char0n Dec 27, 2022
a5a2973
refactor(apidom): remove redundant composition arguments
char0n Dec 28, 2022
4f40bbc
chore(eslint): set ecmaVersion to 2020 in .eslintrc
char0n Dec 28, 2022
8a333fd
test(resolve): add tests for ApiDOM JSON parser
char0n Dec 28, 2022
0afe5f6
test(resolve): add tests for ApiDOM YAML 1.2 parser
char0n Dec 28, 2022
1f776d6
test(resolve): add tests for ApiDOM OpenAPI 3.1.0 JSON parser
char0n Dec 28, 2022
7ebe2ea
test(resolve): add tests for ApiDOM OpenAPI 3.1.0 YAML 1.2 parser
char0n Dec 28, 2022
78f55a7
test(helpers): re-organize tests to reflect code structure
char0n Dec 28, 2022
551c101
feat(resolve): add ApiDOM resolver based on SwaggerClient HTTP client
char0n Dec 29, 2022
62b4745
feat: add OpenAPI 3.1.0 dereference strategy (#2740)
char0n Dec 31, 2022
b6b825a
refactor(helpers): reorganize OpenAPI predicates into separate module
char0n Jan 2, 2023
8be3481
refactor(helpers): reorganize helpers in backward compatible way
char0n Jan 3, 2023
a432487
test(helpers): re-organize tests to reflect code structure
char0n Jan 3, 2023
35e53d5
feat(normalization): introduce normalization for OpenAPI 3.1.0
char0n Jan 3, 2023
a2ca312
refactor(resolver): refactor code to allow using strategy pattern
char0n Jan 3, 2023
19ecbe4
feat(resolver): add support for OpenAPI 3.1.0 resolution
char0n Jan 4, 2023
4070df1
build: set minimum runtime Node.js version to 12.20.0
char0n Jan 5, 2023
f89a60f
fix(resolver): fix useCircularStructure option support in OpenAPI 3.1
char0n Jan 5, 2023
b1f1f04
test(resolver): add tests for OpenAPI 3.1.0 allowMetaPatches option
char0n Jan 6, 2023
1d9a8f8
test(resolver): add tests for OpenAPI 3.1 useCircularStructures opt
char0n Jan 10, 2023
9d6b730
test(resolver): add tests for OpenAPI 3.1 spec obj resolution
char0n Jan 10, 2023
b6c47e7
test(resolver): add tests for OpenAPI 3.1 skipNormalization option
char0n Jan 10, 2023
c7ff14e
refactor(resolver): use constant HTTPS baseURI in non-browser env
char0n Jan 11, 2023
bf6c109
feat(resolver): add support for pathDiscriminator option
char0n Jan 16, 2023
965ca7a
feat(resolver): add support for parameterMacro option
char0n Jan 16, 2023
e1aaf54
feat(resolver): limit depth of dereference to max 100
char0n Jan 16, 2023
5b76f37
feat(resolver): add support for modelPropertyMacro option
char0n Jan 17, 2023
c20b526
feat(subtree-resolver): adapt to support OpenAPI 3.1.0
char0n Jan 17, 2023
8f2145e
test: use original coverage thresholds
char0n Jan 18, 2023
a5c6ea8
refactor(resolver): apply SRP for OpenAPI 3.1 deref strategy
char0n Jan 18, 2023
5dfaca4
feat(resolver): add support for mode resolver option
char0n Jan 19, 2023
85d234f
feat: bundle ApiDOM dependencies
char0n Jan 23, 2023
b286214
chore(release): cut the 3.19.0-alpha.2 release [skip ci]
semantic-release-bot Jan 23, 2023
65ccf1a
docs(README): add compatibility note for OpenAPI 3.1.0
char0n Jan 24, 2023
47b3f0a
Merge branch 'master' into alpha
char0n Jan 24, 2023
a79b7f6
feat: add support for Node.js >= 12.20.0
char0n Jan 25, 2023
ee82497
chore(merge): merge branch master into alpha
char0n Jan 25, 2023
e63f569
chore: fix package-lock.json
char0n Jan 25, 2023
29c40cf
chore(release): cut the 3.19.0-alpha.3 release [skip ci]
semantic-release-bot Jan 25, 2023
cb2aade
docs(README): use v3.19.0.-alpha.3 as start of OpenAPI 3.1.0 support
char0n Jan 25, 2023
517978c
Merge branch 'master' into alpha
char0n Jan 25, 2023
b707419
chore(deps): update ApiDOM to v0.66.0
char0n Jan 25, 2023
0450a6d
Merge branch 'master' into alpha
char0n Jan 26, 2023
ef9d20d
fix(resolver): remove LinkElement hook main dereference
char0n Jan 26, 2023
280f301
feat(resolver): create ApiDOM path -> SwaggerClient path translator
char0n Jan 27, 2023
0dea019
Merge branch 'master' into alpha
char0n Jan 27, 2023
f038e0e
chore: fix package-lock.json
char0n Jan 27, 2023
09872a5
feat(resolver): collect errors in ExampleElement visitor hook
char0n Jan 30, 2023
3983953
feat(resolver): collect errors in ReferenceElement visitor hook (#2803)
char0n Jan 31, 2023
aa7e567
Merge branch 'master' into alpha
char0n Jan 31, 2023
fba4bbc
feat(resolver): collect errors in PathItemElement visitor hook (#2805)
char0n Jan 31, 2023
a098d85
feat(resolver): collect errors in SchemaElement visitor hook (#2807)
char0n Feb 1, 2023
627ee8d
feat(resolver): collect errors in AllOfVisitor hooks (#2809)
char0n Feb 1, 2023
6cef9ff
feat(resolver): collect errors in ModelPropertyMacro visitor hooks (#…
char0n Feb 1, 2023
29ea34d
feat(resolver): collect errors in ParameterMacroVisitor visitor hooks…
char0n Feb 1, 2023
862ddb5
chore(release): cut the 3.19.0-alpha.4 release [skip ci]
semantic-release-bot Feb 1, 2023
c351e16
Merge branch 'master' into alpha
char0n Feb 6, 2023
f055eb8
Merge branch 'master' into alpha
char0n Feb 14, 2023
3c3f516
chore: fix package-lock.json
char0n Feb 14, 2023
2ac1e9f
refactor: consolidate codebase by moving code to more sensible places…
char0n Feb 14, 2023
b7ddc50
feat: expose ApiDOM components as public API (#2828)
char0n Feb 15, 2023
f5bd1a6
docs: document local dev setup (#2830)
char0n Feb 15, 2023
73a8279
test: add OpenAPI 3.1 test for HTTP Client for OAS operations (#2831)
char0n Feb 15, 2023
aea5692
test: add OpenAPI 3.1 test for Tags Interfaces (#2832)
char0n Feb 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 17 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
},
"globals": {
"File": true,
"Blob": true
"Blob": true,
"globalThis": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020,
"ecmaFeatures": {
"impliedStrict": true
}
Expand All @@ -32,6 +34,20 @@
"ignorePackages": true
}
],
"import/no-unresolved": [
2,
{
"ignore": [
"^@swagger-api/apidom-reference/configuration/empty$",
"^@swagger-api/apidom-reference/dereference/strategies/openapi-3-1$",
"^@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/\\$anchor$",
"^@swagger-api/apidom-reference/dereference/strategies/openapi-3-1/selectors/uri$",
"^@swagger-api/apidom-reference/resolve/resolvers/file$",
"^@swagger-api/apidom-reference/resolve/strategies/openapi-3-1$",
"^@swagger-api/apidom-reference/parse/parsers/binary$"
]
}
],
"prettier/prettier": "error",
"no-param-reassign": 0, // needs to be eliminated in future
"no-use-before-define": [2, "nofunc"] // needs to be eliminated in future
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
Expand All @@ -32,6 +34,8 @@ jobs:
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Lint commit message
if: github.ref != 'refs/heads/main' && github.actor != 'dependabot[bot]'
run: git log -1 --pretty=format:"%s" | npx commitlint
Expand All @@ -57,38 +61,48 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Use Node.js 12.4.x
- name: Use Node.js 12.20.0
uses: actions/setup-node@v3
with:
node-version: 12.4.x
node-version: 12.20.0
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"

- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download commonjs build artifacts
uses: actions/download-artifact@v3
with:
name: commonjs

- name: Run commonjs build artifacts on Node.js 12.4.x
- name: Run commonjs build artifacts on Node.js 12.20.0
run: node -p "require('./commonjs')"

- name: Use Node 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"
- name: Run commonjs build artifacts on Node.js 14.x
run: node -p "require('./commonjs')"

- name: Use Node 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"
- name: Run commonjs build artifacts on Node.js 16.x
run: node -p "require('./commonjs')"
18 changes: 5 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,27 @@ on:
workflow_dispatch:
branches:
- alpha

workflow_run:
workflows:
- "Node.js CI"
branches:
- master
types:
- completed

jobs:
release:
name: Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16

registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"
- name: Install dependencies
run: npm ci

env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Semantic Release
id: semantic
uses: cycjimmy/[email protected]
Expand All @@ -41,7 +34,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Release published
if: steps.semantic.outputs.new_release_published == 'true'
run: |
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@swagger-api:registry=https://npm.pkg.github.com
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.17
16.16
3 changes: 2 additions & 1 deletion .releaserc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"release": {
"branches": [
{"name": "master"}
{"name": "master"},
{"name": "alpha", "channel": "alpha", "prerelease": "alpha"}
],
"tagFormat": "v${version}"
},
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ For features known to be missing from 3.x please see the [Graveyard](docs/migrat
For the older version of swagger-js, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-js/tree/2.x).

> *The npm package is called `swagger-client` and the GitHub repository is `swagger-js`.
We'll be consolidating that soon. Just giving you the heads up. You may see references to both names.*
We'll be consolidating that soon. Just giving you the heads-up. You may see references to both names.*

## Compatibility
The OpenAPI Specification has undergone multiple revisions since initial creation in 2010.
Compatibility between Swagger Client and the OpenAPI Specification is as follows:

Swagger Client Version | Release Date | OpenAPI Spec compatibility | Notes
------------------ | ------------ | -------------------------- | -----
3.10.x | 2020-01-17 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 | [tag v3.10.0](https://github.com/swagger-api/swagger-js/tree/v3.10.0)
2.1.32 | 2017-01-12 | 1.0, 1.1, 1.2 | [tag v2.1.32](https://github.com/swagger-api/swagger-js/tree/v2.1.32). This [release](https://github.com/swagger-api/swagger-js/releases/tag/v2.1.32) is only available on GitHub.
Swagger Client Version | Release Date | OpenAPI Spec compatibility | Notes
------------------ |--------------|----------------------------------------| -----
3.19.x | 2023-01-23 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0 | [tag v3.19.0-alpha.3](https://github.com/swagger-api/swagger-js/releases/tag/v3.19.0-alpha.3)
3.10.x | 2020-01-17 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 | [tag v3.10.0](https://github.com/swagger-api/swagger-js/tree/v3.10.0)
2.1.32 | 2017-01-12 | 1.0, 1.1, 1.2 | [tag v2.1.32](https://github.com/swagger-api/swagger-js/tree/v2.1.32). This [release](https://github.com/swagger-api/swagger-js/releases/tag/v2.1.32) is only available on GitHub.

## Documentation

Expand All @@ -51,7 +52,7 @@ Swagger Client Version | Release Date | OpenAPI Spec compatibility | Notes

### Runtime

- Node.js `>=` 12.4.x
- Node.js `>=`12.20.0
- `swagger-client` works in the latest versions of Chrome, Safari, Firefox, and Edge.

## Security contact
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
corejs: { version: 3 },
useBuiltIns: false,
targets: {
node: '12.4',
node: '12.20.0',
},
forceAllTransforms: false,
ignoreBrowserslistConfig: true,
Expand Down
16 changes: 16 additions & 0 deletions config/jest/jest.artifact-commonjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@ module.exports = {
rootDir: path.join(__dirname, '..', '..'),
testEnvironment: 'node',
testMatch: ['**/test/build-artifacts/commonjs.js'],
moduleNameMapper: {
/**
* This is here only until next version of Jest is released - 29.4.x.
* Jest doesn't support package.json imports fields now, so we have
* to provide this workaround.
*
* More information in https://github.com/facebook/jest/issues/12270.
*
*/
'#buffer':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/buffer/protocol-import.cjs',
'#fs':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/fs/protocol-import.cjs',
'#util':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/util/protocol-import.cjs',
},
};
16 changes: 16 additions & 0 deletions config/jest/jest.artifact-es.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@ module.exports = {
rootDir: path.join(__dirname, '..', '..'),
testEnvironment: 'node',
testMatch: ['**/test/build-artifacts/es.js'],
moduleNameMapper: {
/**
* This is here only until next version of Jest is released - 29.4.x.
* Jest doesn't support package.json imports fields now, so we have
* to provide this workaround.
*
* More information in https://github.com/facebook/jest/issues/12270.
*
*/
'#buffer':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/buffer/protocol-import.cjs',
'#fs':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/fs/protocol-import.cjs',
'#util':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/util/protocol-import.cjs',
},
};
16 changes: 16 additions & 0 deletions config/jest/jest.unit.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@ module.exports = {
moduleNameMapper: {
'formdata-node/lib/cjs/fileFromPath.js':
'<rootDir>/node_modules/formdata-node/lib/cjs/fileFromPath.js',
/**
* This is here only until next version of Jest is released - 29.4.x.
* Jest doesn't support package.json imports fields now, so we have
* to provide this workaround.
*
* More information in https://github.com/facebook/jest/issues/12270.
*
*/
'#buffer':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/buffer/protocol-import.cjs',
'#fs':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/fs/protocol-import.cjs',
'#util':
'<rootDir>/node_modules/@swagger-api/apidom-reference/cjs/util/polyfills/util/protocol-import.cjs',
},
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/test/data/',
'<rootDir>/test/jest.setup.js',
'<rootDir>/test/specmap/data/',
'<rootDir>/test/build-artifacts/',
'/__fixtures__/',
'/__utils__/',
],
};
6 changes: 3 additions & 3 deletions config/jest/jest.unit.coverage.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const unitConfig = require('./jest.unit.config');
const unitConfig = require('./jest.unit.config.js');

module.exports = {
...unitConfig,
collectCoverage: true,
collectCoverageFrom: ['src/**/*.js'],
coverageThreshold: {
'./src/': {
branches: 87,
branches: 86,
functions: 91,
lines: 90,
statements: 90,
statements: 89,
},
},
};
4 changes: 2 additions & 2 deletions config/webpack/browser.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const browser = {
}),
new DuplicatesPlugin({
// emit compilation warning or error? (Default: `false`)
emitErrors: true,
emitErrors: false, // https://github.com/FormidableLabs/inspectpack/issues/181
// display full duplicates information? (Default: `false`)
verbose: true,
}),
Expand All @@ -74,7 +74,7 @@ const browserMin = {
devtool: 'source-map',
performance: {
hints: 'error',
maxEntrypointSize: 270000,
maxEntrypointSize: 500000,
maxAssetSize: 1300000,
},
output: {
Expand Down
5 changes: 1 addition & 4 deletions docs/development/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Script name | Description
--- | ---
`build` | Build a new set of JS assets, and output them to `/dist` and `/browser`.
`build:umd:browser` | Build `/dist/swagger-client.browser.*.js` files.
`build:common` | Build `/lib` directory containing ES5 code with commonjs imports.
`build:commonjs` | Build `/lib` directory containing ES5 code with commonjs imports.
`build:es` | Build `/es` directory containing ES5 code with ES6 imports

### Testing
Expand All @@ -31,8 +31,5 @@ Script name | Description

Script name | Description
--- | ---
`security-audit` | Runs npm security audit for production and development dependencies.
`security-audit:dev` | Runs npm security audit for all development dependencies with `moderate` audit level.
`security-audit:prod` | Runs npm security audit for production dependencies with `low` audit level.
`deps:license` | Generates attribution files for production and development dependencies

45 changes: 35 additions & 10 deletions docs/development/setting-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,46 @@
### Prerequisites

- git, any version
- NPM >=6.12.x
- Node.js >=16.16
- NPM >=8.11.0

Generally, we recommend following guidelines from [Node.js Releases](https://nodejs.org/en/about/releases/) to only use `Current`, `Active LTS` or `Maintenance LTS` releases.

Current Node.js:
- Node.js 16.x
- NPM >=7.10.x
### Setting up

Current Node.js Active LTS:
- Node.js >=14.x
- NPM >=6.14.x
If you use [nvm](https://github.com/nvm-sh/nvm), running following command inside this repository will automatically pick the right Node.js version for you:

Current Node.js Maintenance LTS:
- Node.js >12.4
- NPM >=6.12.x
```sh
$ nvm use
```

This repository is using npm packages from https://www.npmjs.com/ and [GitHub packages registry](https://docs.github.com/en/packages/learn-github-packages/introduction-to-github-packages).
To successfully install npm packages that SwaggerEditor requires, you need to [Authenticate to GitHub Packages](https://docs.github.com/en/packages/learn-github-packages/introduction-to-github-packages).

You can authenticate to GitHub Packages with npm by either editing your per-user *~/.npmrc*
file to include your personal access token (classic) or by logging in to npm on the command line using your username and personal access token.

To authenticate by adding your personal access token (classic) to your *~/.npmrc* file,
edit the *~/.npmrc* file for your project to include the following line,
replacing TOKEN with your personal access token. Create a new *~/.npmrc* file if one doesn't exist.
You can find more information about authenticating to GitHub Packages in [GitHub documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages).

```
//npm.pkg.github.com/:_authToken=TOKEN
```


Alternatively, to authenticate by logging in to npm, use the `npm login` command,
replacing USERNAME with your GitHub username, TOKEN with your personal access token (classic),
and PUBLIC-EMAIL-ADDRESS with your email address.

```sh
$ npm login --scope=@swagger-api --registry=https://npm.pkg.github.com

> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
```

### Steps

Expand Down
Loading