0.4.1 • Published 7 months ago

@bratislava/json-schema-xsd-tools v0.4.1

Weekly downloads
-
License
EUPL-1.2
Repository
github
Last release
7 months ago

json-schema-xsd-tools

npm

Installation

yarn add @bratislava/json-schema-xsd-tools

or

npm i @bratislava/json-schema-xsd-tools

Get started

import { loadAndBuildXsd, loadAndBuildDefaultXslt, loadAndValidate, fakeData } from 'json-schema-xsd-tools'
import { readFile, writeFile } from 'node:fs/promises'

const jsonSchema = {
  title: 'A registration form',
  description: 'A simple form example.',
  type: 'object',
  required: ['firstName', 'lastName'],
  properties: {
    firstName: {
      type: 'string',
      title: 'First name',
      default: 'Chuck',
    },
    lastName: {
      type: 'string',
      title: 'Last name',
    },
    telephone: {
      type: 'string',
      title: 'Telephone',
      minLength: 10,
    },
  },
}

const xsd = loadAndBuildXsd(jsonSchema)
await writeFile('schema.xsd', xsd)

const xslt = loadAndBuildDefaultXslt(jsonSchema, 'text')
await writeFile('form.sb.xslt', xslt)

const data = fakeData(jsonSchema)
await writeFile('form.json', data)

const errors = loadAndValidate(xsd, jsonSchema)
console.log(errors) // => []

Documentation

Explore the docs.

Publishing new version

Publish core package

  • Run npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]
  • Or update the version manually in package.json and create a tag with prefix core-v.
  • Push changes.
  • Action publish package to npm. Check the status of workflow run.

License

EUPL-1.2

0.4.1

7 months ago

0.4.0

7 months ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago