1.0.0 • Published 2 years ago

json-schema-md-doc v1.0.0

Weekly downloads
229
License
See LICENSE file
Repository
github
Last release
2 years ago

json-schema-md-doc

Generate markdown documentation for JSON Schemas

Try it out at brianwendt.github.io/json-schema-md-doc

Download JSONSchemaMarkdown.js

Click here to see the Node example.

NOTE: JSONSchemaMarkdown.js supports json-schema.org draft-7. Previous drafts may not generate documentation correctly.

Simple Implementation

NPM Project

npm install json-schema-md-doc
import { JSONSchemaMarkdown } from "json-schema-md-doc";

or HTML

<script src="https://brianwendt.github.io/json-schema-md-doc/lib/JSONSchemaMarkdown.js"></script>

Javascript

// simple schema for the example
const colors_schema = {
	"description": "Choose a color",
	"type": "string",
	"enum": ["red", "amber", "green"]
}

// create an instance of JSONSchemaMarkdown 
const Doccer = new JSONSchemaMarkdown();
// load the schema
Doccer.load(colors_schema);
// generate the markdown
console.log(Doccer.generate());

Result

 _Choose a color_

Type: `string`

Enum Values: 

 1. _"red"_
 2. _"amber"_
 3. _"green"_

_Generated with [json-schema-md-doc](https://brianwendt.github.io/json-schema-md-doc/)_

For a more complete example, check out this JSFiddle.

Extendabale

You may easily extend JSONSchemaMarkdown.js to customize the formatting of your markdown by overriding any method.

class MyDoccer extends JSONSchemaMarkdown {
    constructor(){
        super();
        this.footer = "Thanks for reading the documentation!";
    }
    valueBool(bool) {
        if (typeof bool === "string") {
            return bool;
        } else {
            return (bool) ? "TRUE" : "FALSE"; //uppercase instead of true/false
        }
    }
};
1.0.0

2 years ago

0.1.82

3 years ago

0.1.81

3 years ago

0.1.8

3 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago