Détail du package

@json-schema-tools/titleizer

json-schema-tools18.4kApache-2.01.0.9

Generate deterministic titles for json schemas (AKA ensureAllSchemasHaveTitles)

readme

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.

changelog

1.0.9 (2024-05-07)

Bug Fixes

1.0.8 (2022-10-28)

Bug Fixes

  • bump typescript and typedoc (37429b0)
  • typedoc broken (15c6d00)
  • update typedoc eslint and node typings (f0f3c3a)

1.0.7 (2022-10-26)

Bug Fixes

1.0.6 (2021-06-24)

Bug Fixes

  • update to new meta schema (7bb42fe)

1.0.5 (2021-06-08)

Bug Fixes

1.0.4 (2020-11-03)

Bug Fixes

1.0.3 (2020-10-23)

Bug Fixes

1.0.2 (2020-10-23)

Bug Fixes

1.0.1 (2020-10-23)

Bug Fixes

1.0.0 (2020-08-27)

Bug Fixes

Features