GithubHelp home page GithubHelp logo

json-schema-tools / titleizer Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.38 MB

Generate deterministic titles for json schemas (AKA ensureAllSchemasHaveTitles)

Home Page: https://json-schema-tools.github.io/titleizer/

License: Apache License 2.0

JavaScript 4.66% TypeScript 95.34%
jsonschema json-rpc json-api open-api open-rpc typescript

titleizer's Introduction

JSON Schema Titleizer

CircleCI branch Dependabot status npm GitHub release GitHub commits since latest release

A tool to ensure that a schema and all its subschemas have a title. If there is no title present, one will be deterministically generated based on the schemas contents.

Features

  • circular reference detection & handling
  • synchronous - doesn't touch the filesystem or make network requests. (use @json-schema-tools/dereferencer first if you have references)
  • generate subschema-dependent titles
  • always have unique titles for your json-schema

Getting Started

npm install @json-schema-tools/titleizer
const titleizer = require("@json-schema-tools/titleizer").default;
//import titleizer from "@json-schema-tools/titleizer"

const mySchema = {
  type: "object",
  properties: {
    foo: {
      title: "foo",
      type: "array",
      items: { type: "string" }
    },
    bar: {
      title: "bar",
      anyOf: [
        { type: "string" },
        { type: "number" }
      ]
    }
  }
};

console.log(JSON.stringify(titleizer(mySchema), undefined, "  "));

Output from running the above:

{
  "type": "object",
  "properties": {
    "foo": {
      "title": "foo",
      "type": "array",
      "items": {
        "type": "string",
        "title": "string_doaGddGA"
      }
    },
    "bar": {
      "title": "bar",
      "anyOf": [
        {
          "type": "string",
          "title": "string_doaGddGA"
        },
        {
          "type": "number",
          "title": "number_Ho1clIqD"
        }
      ]
    }
  },
  "title": "objectOf_foo_bar_Bd1o3wyq"
}

Contributing

How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.