{"id":16193247,"url":"https://github.com/koriym/json-schema-connected","last_synced_at":"2026-01-11T16:49:15.114Z","repository":{"id":248363700,"uuid":"828489916","full_name":"koriym/json-schema-connected","owner":"koriym","description":"A converter that transforms JSON schemas into array shape format, SQL, or Markdown, resolving $ref references.","archived":false,"fork":false,"pushed_at":"2024-07-17T06:35:43.000Z","size":292,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"1.x","last_synced_at":"2025-03-24T22:46:03.596Z","etag":null,"topics":["array-shape","converter","json-sche","markdown","npm-package","phpstan","psalm","sql"],"latest_commit_sha":null,"homepage":"https://koriym.github.io/json-schema-connected/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koriym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-14T10:06:07.000Z","updated_at":"2024-09-13T22:40:07.000Z","dependencies_parsed_at":"2024-11-03T04:41:41.209Z","dependency_job_id":"7d167de5-5821-4cb2-b961-2dfade11002a","html_url":"https://github.com/koriym/json-schema-connected","commit_stats":null,"previous_names":["koriym/json-schema-to-array-shape","koriym/json-schema-connected"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2Fjson-schema-connected","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2Fjson-schema-connected/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2Fjson-schema-connected/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2Fjson-schema-connected/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koriym","download_url":"https://codeload.github.com/koriym/json-schema-connected/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246768229,"owners_count":20830627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array-shape","converter","json-sche","markdown","npm-package","phpstan","psalm","sql"],"created_at":"2024-10-10T08:14:26.338Z","updated_at":"2026-01-11T16:49:15.073Z","avatar_url":"https://github.com/koriym.png","language":"JavaScript","readme":"# JSON-Schema-Connected\n[![Node.js CI](https://github.com/koriym/json-schema-connected/actions/workflows/nodejs.yml/badge.svg)](https://github.com/koriym/json-schema-to-array-shape/actions/workflows/nodejs.yml)\n\n\u003cimg src=\"images/json-schema-connected.png\" width=\"250px\" alt=\"logo\"\u003e\n\nThis project provides a set of utilities for working with JSON Schemas. It includes three main libraries:\n\n1. Array Shape Generator\n2. SQL Schema Generator\n3. Markdown Documentation Generator\n\nThese utilities help you generate array shape @var type, create SQL tables, and produce documentation from your JSON Schemas.\n\n## Online Service\n\nYou can use the online version of this converter without installing anything on your local machine. Visit the following URL:\n\n[json-schema-connected Converter](https://koriym.github.io/json-schema-connected/)\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Array Shape Generator](#array-shape-generator)\n    - [SQL Schema Generator](#sql-schema-generator)\n    - [Markdown Documentation Generator](#markdown-documentation-generator)\n- [API Reference](#api-reference)\n- [Examples](#examples)\n- [JSON Schema-Centric Data Modeling](#json-schema-centric-data-modeling)\n    - [Benefits](#benefits)\n    - [Background](#background)\n    - [Design Philosophy](#design-philosophy)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nTo use these utilities, clone this repository and install the dependencies:\n\n```bash\ngit clone https://github.com/koriym/json-schema-connected.git\ncd json-schema-connected\nnpm install\n```\n\n## Usage\n\n### Array Shape Generator\n\nThe Array Shape Generator creates a sample array based on your JSON Schema.\n\n```javascript\nconst { jsonSchemasToArrayShape } = require('./schema-array-shape');\n\nconst schema = {\n  type: 'object',\n  properties: {\n    id: { type: 'integer' },\n    name: { type: 'string' }\n  }\n};\n\nconst arrayShape = jsonSchemasToArrayShape(schema);\nconsole.log(arrayShape);\n```\n\n### SQL Schema Generator\n\nThe SQL Schema Generator creates SQL `CREATE TABLE` statements from your JSON Schema.\n\n```javascript\nconst { jsonSchemaToCreateTable, convertJsonSchemasToCreateTables } = require('./schema-sql');\n\n// For a single schema\nconst singleSchema = { /* your JSON schema here */ };\nconst sqlStatement = jsonSchemaToCreateTable(singleSchema, 'tableName');\nconsole.log(sqlStatement);\n\n// For multiple schemas\nconst multipleSchemas = [ /* array of JSON schemas */ ];\nconst allSql = convertJsonSchemasToCreateTables(JSON.stringify(multipleSchemas));\nconsole.log(allSql);\n```\n\n### Markdown Documentation Generator\n\nThe Markdown Documentation Generator creates readable documentation from your JSON Schema.\n\n```javascript\nconst { jsonSchemaToMarkdown, convertJsonSchemasToMarkdowns } = require('./schema-markdown');\n\n// For a single schema\nconst singleSchema = { /* your JSON schema here */ };\nconst markdown = jsonSchemaToMarkdown(singleSchema, __dirname);\nconsole.log(markdown);\n\n// For multiple schemas\nconst multipleSchemas = [ /* array of JSON schemas */ ];\nconst fullMarkdown = convertJsonSchemasToMarkdowns(multipleSchemas, __dirname);\nconsole.log(fullMarkdown);\n```\n## Examples\n\nHere are some practical examples demonstrating how to use the JSON Schema Utilities in various scenarios:\n\n### 1. Basic Usage\n\nThis example shows how to use all three utilities with a simple JSON Schema:\n\n```javascript\nconst fs = require('fs');\nconst { jsonSchemasToArrayShape } = require('./schema-array-shape');\nconst { jsonSchemaToCreateTable } = require('./schema-sql');\nconst { jsonSchemaToMarkdown } = require('./schema-markdown');\n\n// Define a simple JSON Schema\nconst schema = {\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"title\": \"Person\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\",\n      \"description\": \"The person's full name\"\n    },\n    \"age\": {\n      \"type\": \"integer\",\n      \"description\": \"Age in years\",\n      \"minimum\": 0\n    },\n    \"email\": {\n      \"type\": \"string\",\n      \"format\": \"email\",\n      \"description\": \"Email address\"\n    }\n  },\n  \"required\": [\"name\", \"age\"]\n};\n\n// Generate array shape\nconsole.log(\"Array Shape:\");\nconsole.log(JSON.stringify(jsonSchemasToArrayShape(schema), null, 2));\n\n// Generate SQL\nconsole.log(\"\\nSQL Create Table Statement:\");\nconsole.log(jsonSchemaToCreateTable(schema, \"person\"));\n\n// Generate Markdown\nconsole.log(\"\\nMarkdown Documentation:\");\nconsole.log(jsonSchemaToMarkdown(schema, __dirname));\n```\n\n### 2. Integrating with a Web Application\n\nThis example shows how you might integrate these utilities into a simple Express.js web application:\n\n```javascript\nconst express = require('express');\nconst { jsonSchemasToArrayShape } = require('./schema-array-shape');\nconst { jsonSchemaToCreateTable } = require('./schema-sql');\nconst { jsonSchemaToMarkdown } = require('./schema-markdown');\n\nconst app = express();\napp.use(express.json());\n\napp.post('/generate', (req, res) =\u003e {\n  const schema = req.body;\n  \n  const arrayShape = jsonSchemasToArrayShape(schema);\n  const sqlStatement = jsonSchemaToCreateTable(schema, 'generated_table');\n  const markdown = jsonSchemaToMarkdown(schema, __dirname);\n\n  res.json({\n    arrayShape,\n    sqlStatement,\n    markdown\n  });\n});\n\nconst PORT = process.env.PORT || 3000;\napp.listen(PORT, () =\u003e console.log(`Server running on port ${PORT}`));\n```\n\nThese examples demonstrate various ways to use the JSON Schema Utilities in different contexts, from basic usage to integration in a web application. They provide a starting point for users to understand how to incorporate these tools into their own projects.\n\n## JSON Schema-Centric Data Modeling\n\n### Benefits\n\nData modeling centered around JSON Schema offers several significant advantages:\n\n1. **Language-Agnostic**: JSON Schema is independent of any programming language, making it ideal for cross-platform and multi-language projects.\n\n2. **Self-Documenting**: JSON Schema provides a clear, readable description of your data structure, serving as both specification and documentation.\n\n3. **Validation**: JSON Schema allows for automatic validation of data, ensuring data integrity across your application.\n\n4. **Tooling Support**: Many tools and libraries support JSON Schema, allowing for code generation, data mocking, and more.\n\n5. **Flexibility**: JSON Schema can describe simple to complex data structures, accommodating a wide range of use cases.\n\n6. **Interoperability**: JSON Schema facilitates easy data exchange between different systems and services.\n\n7. **Version Control Friendly**: Being text-based, JSON Schema works well with version control systems, making it easy to track changes in your data model over time.\n\n### Background\n\nJSON Schema emerged as a response to the growing popularity of JSON (JavaScript Object Notation) as a data interchange format. While JSON itself is lightweight and easy to read, it lacks a built-in way to describe the structure of data or enforce constraints.\n\nJSON Schema was introduced to address these limitations. It provides a vocabulary to annotate and validate JSON documents, offering a contract for what JSON data should look like. This concept has roots in XML Schema and other data description formats, but it's designed to be more lightweight and JSON-centric.\n\n### Design Philosophy\n\nThe design philosophy behind JSON Schema-centric data modeling emphasizes several key principles:\n\n1. **Separation of Concerns**: By defining data structure separately from code, we achieve a clear separation between data modeling and application logic.\n\n2. **Single Source of Truth**: The JSON Schema becomes the authoritative definition of your data model, reducing inconsistencies across different parts of your system.\n\n3. **Design-First Approach**: Encouraging developers to think about and define their data structures before implementation leads to more thoughtful and robust system designs.\n\n4. **Extensibility**: JSON Schema is designed to be extensible, allowing for custom vocabularies and extensions to meet specific needs.\n\n5. **Human and Machine Readable**: The format strikes a balance between being easily understood by humans and efficiently processed by machines.\n\n6. **Reusability**: Schemas can be shared and reused across different parts of an application or even between different applications, promoting consistency and reducing duplication.\n\nBy centering your data modeling around JSON Schema and leveraging tools like those provided in this project, you can create more maintainable, consistent, and well-documented data models for your applications.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoriym%2Fjson-schema-connected","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoriym%2Fjson-schema-connected","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoriym%2Fjson-schema-connected/lists"}