jsonschema-types

0.0.6 • Public • Published

npm version

jsonschema-types

This package enables building Jsonschemas as Typescript classes. It uses decorators to build the jsonschema

You can access the schema with

new TestSchema().jsonschema

Test the schema with validate It uses the validate function of jsonschema

Example

@schemaOptions({ id: '/TestSchemaCreate' })
export class TestSchema extends Schema {
  @prop({ required: true, minimum: 1, maximum: 4 })
  testProp!: string

  @prop({ enum: ETEST})
  what!: ETEST

  @prop({})
  other!: TestSchema2

  @prop({ type: Number, maxItems: 3 })
  numberList!: number[]

  @prop({ type: TestSchema2, minItems: 1, uniqueItems: true })
  otherList!: TestSchema2[]

  @prop({ multipleOf: 3 })
  multiple!: number

  @prop({ minLength: 3, maxLength: 5, required: true })
  minLen!: string

  @prop({ pattern: '/abc/' })
  regex!: string

  @prop({ exclusiveMinimum: true, exclusiveMaximum: true })
  exclusive!: number
}

Dependents (0)

Package Sidebar

Install

npm i jsonschema-types

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

14.9 kB

Total Files

11

Last publish

Collaborators

  • leopold.kamp