Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/json-schema-tools/titleizer
Generate deterministic titles for json schemas (AKA ensureAllSchemasHaveTitles)
https://github.com/json-schema-tools/titleizer
json-api json-rpc jsonschema open-api open-rpc typescript
Last synced: 2 months ago
JSON representation
Generate deterministic titles for json schemas (AKA ensureAllSchemasHaveTitles)
- Host: GitHub
- URL: https://github.com/json-schema-tools/titleizer
- Owner: json-schema-tools
- License: apache-2.0
- Created: 2020-08-27T05:30:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-22T08:51:02.000Z (4 months ago)
- Last Synced: 2024-09-30T15:13:07.826Z (3 months ago)
- Topics: json-api, json-rpc, jsonschema, open-api, open-rpc, typescript
- Language: TypeScript
- Homepage: https://json-schema-tools.github.io/titleizer/
- Size: 1.22 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# JSON Schema Titleizer
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
```sh
npm install @json-schema-tools/titleizer
``````js
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](CONTRIBUTING.md), [BUILDING.md](BUILDING.md) and [RELEASING.md](RELEASING.md) respectively. Commits in this repository follow the [CONVENTIONAL_COMMITS.md](CONVENTIONAL_COMMITS.md) specification.