@bratislava/json-schema-xsd-tools
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

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

Weekly Downloads

1

Version

0.4.1

License

EUPL-1.2

Unpacked Size

1.99 MB

Total Files

64

Last publish

Collaborators

  • mpinter
  • skifahrer
  • marekbodingerba
  • kristianduda
  • inovacie.bratislava