Skip to content

Commit

Permalink
BREAKING CHANGE: Revert "fix(versioning): revert all commits from 3.2…
Browse files Browse the repository at this point in the history
….0 onwards to create new minor release for 3.x" (#57)
  • Loading branch information
jonluca authored Mar 30, 2023
1 parent 70eed88 commit 44a91d0
Show file tree
Hide file tree
Showing 69 changed files with 8,181 additions and 18,352 deletions.
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/**"],
};
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- run: npm ci
- run: npm run build --if-present
- run: npm test
node-version: 18
- 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
29 changes: 14 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ jobs:
strategy:
matrix:
node-version:
- 12
- 14
- 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
85 changes: 63 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 @@ -123,21 +122,63 @@ If the handler is not provided, the default handler is used. If `additionalPrope

See `test/pattern_properties.test.js` for examples how this works.

#### `definitionKeywords` (array)

By default, definitions are not converted. If your documents follow the convention of having a definitions object at the root of a (sub)schema, you can set definitionKeywords to `['definitions']`.

```js
var schema = {
definitions: {
sharedDefinition: {
type: "object",
properties: {
foo: {
type: "string",
nullable: true,
},
},
},
},
};
var convertedSchema = toJsonSchema(schema, {
definitionKeywords: ["definitions"],
});
console.log(convertedSchema);
```

prints

```js
{
$schema: 'http://json-schema.org/draft-04/schema#',
definitions: {
sharedDefinition: {
type: 'object',
properties: {
foo: {
type: ['string', 'null']
}
}
}
}
}
```

## Converting OpenAPI parameters

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 +241,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.

Loading

0 comments on commit 44a91d0

Please sign in to comment.