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

docson

v2.1.0

Published

Documentation for your JSON types

Downloads

3,412

Readme

Docson

Documentation for your JSON types.

Give Docson a JSON schema and it will generate a beautiful documentation.

Features

  • JSON schema v4 keywords.
  • Runs entirely in the browser.
  • Render schema descriptions with markdown

Installation

  • Place the Docson distribution on the web server serving the schemas (to avoid cross-origin issues).

Usage

Via cli tool

$ docson -d ./schemas/
server ready and running at localhost:3000

# and then...
firefox http://localhost:3000/schemas/ship.json

As a webpage widget

To include a Docson schema documentations on any page (wiki, ...) without worrying about messing up with javascript libraries and cross-origin issues:

  • Install Docson somewhere as described above.

  • Place the following script tags in the including page, nothing else is needed:

Add to a webpage

Note that you can refer to a sub-schema by adding a json-pointer path as 'dollar-parameter': index.html#/docson/examples/example.json$items

Typson

You can directly reference your JSON types defined as TypeScript interfaces. If the path ends with .ts, Docson will use Typson to convert the Type Scripts to schema in order to generate the documentation.

For example, index.html#/typson/example/invoice/line.ts$InvoiceLine is the documentation of line.ts.

You need to install Typson by yourself on your server. It must be in a directory named typson located at the same level as the docson directory.

Swagger

You can adapt Swagger UI to display Docson-generated model documentation instead of the builtin signatures.

See how it looks like in the Swagger Docson example

In Swagger UI's index.html, include the Swagger integration script after other script tags:

  <script src='/path-to-docson/docson-swagger.js' type='text/javascript'></script>

Also, you will need a patched version of Swagger Client so that the raw json-schema model is visible from Docson. Either replace the swagger.js file in your Swagger UI disctribution or take it directly from github by replacing

   <script src='/lib/swagger.js' type='text/javascript'></script>

with

  <script src='https://raw2.github.com/lbovet/swagger-js/models-exposed/lib/swagger.js' type='text/javascript'></script>

For a better layout of parameter models, you may want to change the width of some elements:

  <style>
      .swagger-ui-wrap {
          max-width: 1200px;
      }
      .swagger-ui-wrap .body-textarea {
          width: 200px;
      }
  </style>

Integration

You can also integrate Docson in your application and use its javascript API:

docson.doc(element, schema, ref)
  • element is the element which will host the documentation. Either a DOM element (id or object) or jQuery element.
  • schema is the URI or path to the schema or a string containing the schema source itself.
  • ref is an optional json-pointer path to a sub-schema.

Examples:

Limitations

  • Mixing unrelated keywords can lead to unexpected results.

Not implemented:

  • Non-primitive values in enums and default values
  • dependencies, additionalItems, patternProperties

Development

Please pull-request your failing schemas in the tests/ folder and open an issue describing the expected result.

Bitdeli Badge