npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

schematype

v0.0.7

Published

SchemaType Validator

Downloads

3

Readme

schematype

SchemaType Compiler, Validator, Translator, Formatter and Generator

Synopsis

# Check if a YAML file is well-formed:
> stp validate -s file-schema.stp file.yaml

Description

The schematype package installs a CLI program called stp. The stp tool has many functions related to SchemaType. It can do data document (YAML, JSON, others) validation. It can import other kinds of schema into SchemaType and it can export SchemaType back into those formats. It can compile and reformat SchemaType (.stp) files. Most importantly, it can generate all kinds of software code from SchemaType files. These include:

  • Input editors
  • Client struct/typedef code
  • Server model code
  • Database SQL
  • Data visualizers
  • Test input
  • Documentation

Installation

The stp command is currently written in Node.js. To install it, run:

> npm install -g schematype
> stp -h

You can also easily run it as with Docker, if you have Docker installed and don't want to install it with Node.js/npm. See below.

Usage

The stp command has many functions. It has a subcommand for each function. The general usage is:

stp <command> [<option>...] [<file>...]

Use this to get a help overview:

stp -h

this to see the full help:

stp help

and this to get help for a specific command:

stp help <command>

See below for a full description of each command and option.

Running with Docker

If you use Docker, you don't need to install schematype, stp or Node.js at all. Just create a shell alias:

alias stp='docker run --rm -it -v $PWD:/data schematype/stp'

then you can use the stp alias just like an installed version of stp.

Commands

These commands are currently supported:

  • compile -- Compile a .stp file to a .stpx file.
  • export -- Export a .stp file to a .jsc (JSON Schema) file.
  • validate -- Validate one or more data documents against a schema.

These commands will be implemented soon:

  • convert -- Convert a data file from one format to another
  • create -- Create a .stp file from valid data files
  • format -- Reformat a .stp file to a desired style
  • generate -- Generate code from a schema file
  • import -- Import .stp from other formats

Options

The --quiet and --verbose options are available for all commands. The --schema option is used for all commands that need a schema. The --input and --output options specify files explicitly when they can't be inferred from a file list. The --from and --to options specify the input and output formats when they can't be inferred from file extensions or content heuristics.

Many commands accept a list of file paths to perform the specified operation on. Input files can either be local paths or they can be URLs. You can also use the --input option to specify one input explicitly. The --input option should not be used along with a file list. Use one or the other.

The stp command has the following options:

  • -q, --quiet Tell stp to be less noisy about what it is doing.
  • -v, --verbose Tell stp to be more moisy about what it is doing.
  • -s, --schema=<file> Specify the schema to use for this operation. Schema files end with .stp and compiled schema files end with .stpx. If the schema path is specified without a file extension, stp will look for a .stpx file, and then for a .stp file. If the path is a directory (URLs should end with /), stp will look for index.stpx or index.stp file.
  • -i, --input=<file> Specify a single input file path (or URL) for the operation. Use this in place of the file list argument if appropriate. A value of - indicates that the input will be read from STDIN. The file extension will be used as the --from value, if that is needed.
  • -o, --output=<file> Specify a single output file path for the operation. A value of - indicates that the output will be written to STDOUT. The file extension will br used as the --to value, if needed.
  • -f, --from=<format> SchemaType commands can operate on different types of input data (like YAML or JSON) for example. The --from option explicitly specifies the input format. Usually stp can correctly guess the input format. Use this option when it can't.
  • -t, --to=<format> Explicitly specify the output format for the command.
  • -l, --layout=<layout> When stp writes output files, there is often more than one way to do it. This option specifies the output layout style to use. Current styles are:
    • compact Write .stp files in a more compact form. Write JSON files without whitespace between tokens. The JSON default is a pretty style.
    • explicit Write .stp files in a more explicit style. The default is a medium between compact and explicit.

Examples

You can try out stp yourself with these commands:

> git clone https://github.com/schematype/schematype-js
> cd schematype-js/test/manifest
> stp validate -s manifest.stp manifest.yml
> stp compile -i manifest.stp
> stp export -i manifest.stp -t jsc

Or you can skip the git clone and do it using URLs for the file names:

> stp validate -s \
      https://raw.githubusercontent.com/schematype/schematype-js/master/test/manifest/manifest.stp \
      https://raw.githubusercontent.com/Stackato-Apps/django-cms/stackato-3.6/manifest.yml

See Also

  • "JSON Schema"<...>