Skip to content

Commit cad7de9

Browse files
authored
* [email protected], [email protected] * Remove broken Github Actions badge * Update peer dependency version warning in README
1 parent 4a40b88 commit cad7de9

File tree

7 files changed

+10
-12
lines changed

7 files changed

+10
-12
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# class-validator-jsonschema
22

3-
![CI status](https://github.com/epiphone/class-validator-jsonschema/workflows/.github/workflows/test.yml/badge.svg?branch=master) [![codecov](https://codecov.io/gh/epiphone/class-validator-jsonschema/branch/master/graph/badge.svg)](https://codecov.io/gh/epiphone/class-validator-jsonschema) [![npm version](https://badge.fury.io/js/class-validator-jsonschema.svg)](https://badge.fury.io/js/class-validator-jsonschema)
3+
[![codecov](https://codecov.io/gh/epiphone/class-validator-jsonschema/branch/master/graph/badge.svg)](https://codecov.io/gh/epiphone/class-validator-jsonschema) [![npm version](https://badge.fury.io/js/class-validator-jsonschema.svg)](https://badge.fury.io/js/class-validator-jsonschema)
44

55
Convert [class-validator](https://github.com/typestack/class-validator)-decorated classes into OpenAPI-compatible JSON Schema. The aim is to provide a best-effort conversion: since some of the `class-validator` decorators lack a direct JSON Schema counterpart, the conversion is bound to be somewhat opinionated. To account for this multiple extension points are available.
66

77
## Installation
88

99
`npm install class-validator-jsonschema`
1010

11-
Note that the library is **only compatible with `class-validator` versions 0.12 or higher**!
12-
13-
Try installing `[email protected]` in case you're stuck with an older `class-validator` version.
11+
**Note the peer dependency versions** in [package.json](./package.json). Try installing a previous major version of `class-validator-jsonschema` in case you're stuck with older peer dependencies.
1412

1513
## Usage
1614

@@ -213,8 +211,8 @@ would resolve to classes `Array` and `Promise` in JSON Schema. To work around th
213211

214212
```typescript
215213
import { Type } from 'class-transformer'
216-
import { defaultMetadataStorage } from 'class-transformer/storage'
217214
import { validationMetadatasToSchemas } from 'class-validator-jsonschema'
215+
const { defaultMetadataStorage } = require('class-transformer/cjs/storage') // See https://github.com/typestack/class-transformer/issues/563 for alternatives
218216

219217
class User {
220218
@ValidateNested({ each: true })

__tests__/additionalProperties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { IsString, MinLength, ValidateNested } from 'class-validator'
33
import { validationMetadatasToSchemas } from '../src'
44
import { Type } from 'class-transformer'
5-
import { defaultMetadataStorage } from 'class-transformer/storage'
5+
const { defaultMetadataStorage } = require('class-transformer/cjs/storage')
66

77
class User {
88
@IsString()

__tests__/classTransformer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// tslint:disable:no-submodule-imports
22
import { Type } from 'class-transformer'
3-
import { defaultMetadataStorage } from 'class-transformer/storage'
43
import {
54
ArrayMinSize,
65
getFromContainer,
@@ -11,6 +10,7 @@ import {
1110
} from 'class-validator'
1211

1312
import { validationMetadatasToSchemas } from '../src'
13+
const { defaultMetadataStorage } = require('class-transformer/cjs/storage')
1414

1515
class ValidationError {
1616
@IsString({ each: true })

__tests__/exclude.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// tslint:disable:no-submodule-imports
22
import { Exclude } from 'class-transformer'
3-
import { defaultMetadataStorage } from 'class-transformer/storage'
43
import { Allow, IsString } from 'class-validator'
54
import { validationMetadatasToSchemas } from '../src'
5+
const { defaultMetadataStorage } = require('class-transformer/cjs/storage')
66

77
class Parent {
88
@Allow()

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"typescript": "^4.1.3"
5454
},
5555
"peerDependencies": {
56-
"class-transformer": "0.2.3 - 0.3.1",
57-
"class-validator": "^0.12.0"
56+
"class-transformer": "^0.4.0",
57+
"class-validator": "^0.13.1"
5858
}
5959
}

src/defaultConverters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export const defaultConverters: ISchemaConverters = {
277277
format: 'uuid',
278278
type: 'string',
279279
},
280-
[cv.LENGTH]: (meta) => {
280+
[cv.IS_LENGTH]: (meta) => {
281281
const [minLength, maxLength] = meta.constraints
282282
if (maxLength || maxLength === 0) {
283283
return { minLength, maxLength, type: 'string' }

src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MetadataStorage as ClassTransformerMetadataStorage } from 'class-transformer/metadata/MetadataStorage' // tslint:disable-line:no-submodule-imports
1+
import type { MetadataStorage as ClassTransformerMetadataStorage } from 'class-transformer/types/MetadataStorage' // tslint:disable-line:no-submodule-imports
22
import {
33
getMetadataStorage,
44
MetadataStorage,

0 commit comments

Comments
 (0)