Skip to content

Rewrote in typescript, changed testing suite to vite, ESM & CJS builds #45

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 0 additions & 12 deletions .editorconfig

This file was deleted.

31 changes: 22 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@ module.exports = {
browser: true,
commonjs: true,
es6: true,
node: true
node: true,
},
extends: [
"eslint:recommended"
],
extends: ["prettier", "eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},
parserOptions: {
ecmaVersion: 2018
ecmaVersion: 2018,
},
plugins: ["prettier", "unused-imports", "@typescript-eslint"],
rules: {
}
}
"linebreak-style": ["error", "unix"],
quotes: ["error", "double"],
semi: ["error", "always"],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
},
],
},
ignorePatterns: ["dist/**"],
};
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm run build --if-present
- run: npm test
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn test
- run: npx semantic-release --branches main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ jobs:
- 16
- 18
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm run build --if-present
npm test
env:
CI: true
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, build, and test
run: |
yarn --frozen-lockfile
yarn build --if-present
yarn lint
yarn test
env:
CI: true
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
*.swp
build.sh
.coveralls.yml
.node-version
.nyc_output
yarn.lock
resolved.yaml

# Logs
logs
*.log
npm-debug.log*

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage
# (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
dist
.idea
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ If you need to do the conversion in reverse, checkout [json-schema-to-openapi-sc

## Features

* converts OpenAPI v3.0 Schema Object to JSON Schema Draft 4
* converts OpenAPI v3.0 Parameter Object to JSON Schema Draft 4
* deletes `nullable` and adds `"null"` to `type` array if `nullable` is `true`
* supports deep structures with nested `allOf`s etc.
* removes [OpenAPI specific properties](https://spec.openapis.org/oas/v3.0.3.html#fixed-fields-20) such as `discriminator`, `deprecated` etc. unless specified otherwise
* optionally supports `patternProperties` with `x-patternProperties` in the Schema Object
- converts OpenAPI v3.0 Schema Object to JSON Schema Draft 4
- converts OpenAPI v3.0 Parameter Object to JSON Schema Draft 4
- deletes `nullable` and adds `"null"` to `type` array if `nullable` is `true`
- supports deep structures with nested `allOf`s etc.
- removes [OpenAPI specific properties](https://spec.openapis.org/oas/v3.0.3.html#fixed-fields-20) such as `discriminator`, `deprecated` etc. unless specified otherwise
- optionally supports `patternProperties` with `x-patternProperties` in the Schema Object

**NOTE**: `$ref`s are not handled in any way, so please use a resolver such as [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser) or [swagger-cli bundle](https://www.npmjs.com/package/swagger-cli) prior to using this package.

Expand All @@ -38,13 +38,12 @@ npm install --save @openapi-contrib/openapi-schema-to-json-schema
Here's a small example to get the idea:

```js

var toJsonSchema = require('@openapi-contrib/openapi-schema-to-json-schema');
var toJsonSchema = require("@openapi-contrib/openapi-schema-to-json-schema");

var schema = {
type: 'string',
format: 'date-time',
nullable: true
type: "string",
format: "date-time",
nullable: true,
};

var convertedSchema = toJsonSchema(schema);
Expand Down Expand Up @@ -80,8 +79,8 @@ For example

```js
var schema = {
type: 'string',
format: 'date'
type: "string",
format: "date",
};

var convertedSchema = toJsonSchema(schema, { dateToDateTime: true });
Expand Down Expand Up @@ -128,16 +127,16 @@ See `test/pattern_properties.test.js` for examples how this works.
OpenAPI parameters can be converted:

```js
var toJsonSchema = require('@openapi-contrib/openapi-schema-to-json-schema').fromParameter;
var toJsonSchema = require("@openapi-contrib/openapi-schema-to-json-schema").fromParameter;

var param = {
name: 'parameter name',
in: 'query',
name: "parameter name",
in: "query",
schema: {
type: 'string',
format: 'date'
}
}
type: "string",
format: "date",
},
};

var convertedSchema = toJsonSchema(param);

Expand Down Expand Up @@ -200,10 +199,10 @@ This package is [Treeware](https://treeware.earth). If you use it in production,
- [mikunn][] for originally creating this package.
- [All Contributors][link-contributors]

[Stoplight]: https://stoplight.io/
[stoplight]: https://stoplight.io/
[mikunn]: https://github.com/mikunn
[link-contributors]: https://github.com/openapi-contrib/openapi-schema-to-json-schema/graphs/contributors

## Copyright
## Copyright

Copyright 2021 the [OpenAPI Contrib organization](https://github.com/openapi-contrib). Code released under the [MIT License](https://github.com/openapi-contrib/openapi-schema-to-json-schema/blob/main/LICENSE).
32 changes: 0 additions & 32 deletions index.d.ts

This file was deleted.

88 changes: 0 additions & 88 deletions index.js

This file was deleted.

7 changes: 0 additions & 7 deletions lib/convert.js

This file was deleted.

38 changes: 0 additions & 38 deletions lib/converters/parameter.js

This file was deleted.

Loading