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

json-schema-docs

v0.1.2

Published

a framework agnostic documentation generator for your json schemas.

Downloads

11

Readme

json-schema-docs

a framework agnostic documentation generator for your json schemas.

it feels a little weird to write documentation for something that generates documentation...

See the example app here <- this is out of date, but you'll get the idea

i got annoyed writing documentation, when i felt like our json validation should be self documenting.
this for the most part is is json schema compliant. i'm not supporting json pointers. in all honestly, i don't really like them.
THAT BEING SAID, if 1 person asks me to add json pointer support, i will.

How to use it

npm install json-schema-docs --save
var schemaDocs = require('json-schema-docs')
var docs = schemaDocs({
    title: "My Api Docs",
    schema: require('./schemas'),
    // plus any optional params, currently, you can customize the styles
})
router.get('/docs', function (req, res) {
    res.send(docs)
})

A lot of the styles are configurable. Here are all the defaults, you can override any of them:

{
    code: {
        color: "#FFF",
        backgroundColor: "#042A48",
    },
    thead: {
        th: {
            color: "#FFF",
            backgroundColor: "#042A48",
        },
    },
    th: {
        color: "#FFF",
        backgroundColor: "#91A0AC",
    },
    td: {
        color: "#FFF",
        backgroundColor: "#C3C6C8",
    },
    jsonMarkup: {
        color: "#C3C6C8",
        backgroundColor: "#042A48",
        boolean: {
            color: "#A8573D",
        },
        string: {
            color: "#AA8C3D",
        },
        null: {
            color: "#CFCFCF",
        },
        number: {
            color: "#92B076",
        },
    },
}

If you're using JSON schema. here is what you need to add to your schema to make this work

basically, if you structure your schema like RESTful routes, you'll have a good time.

{    
    resource: "Name of resource, e.g. 'Users'",
    description: "Any description you have to have, e.g. 'URIs for users'",
    rootUri: "The root of uri of your resource, e.g. /users",
    create: {
        name: "Create",
        uri: "/",
        method: "POST",
        type: "object",
        properties: {
            // your api props
        }
        response: {
            status: {
                code: 201,
            },
            type: "etc...."
        },
        addresses: {
            resource: "Users/Addresses",
            description: "Addresses for users",
            rootUri: "/:id/addresses",
            getById: {
                name: "Create",
                uri: "/:addressId",
                method: "GET",
                // etc...
            }
        }
    }
}

root uris will inherit whatever resource they're inside, and uris will inherit their root uri

You can also add example responses. look in the schemas folder for examples. there might be some changes, though. my coworker had a good idea for generating examples with another tool i'll be writing that's going to build on this schema structure.

There's currently support for headers, but i don't really the way it's done. i know what i want now. when i get time i'm going to change it to something that fits my js stackvana better