{"id":13451969,"url":"https://github.com/supermodel/supermodel-cli","last_synced_at":"2025-03-23T19:33:21.237Z","repository":{"id":57374847,"uuid":"76061889","full_name":"supermodel/supermodel-cli","owner":"supermodel","description":"Boring data modeling","archived":true,"fork":false,"pushed_at":"2019-02-06T08:20:17.000Z","size":1481,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T19:37:38.313Z","etag":null,"topics":["avro","avro-schema","graphql","json","json-ld","json-schema","openapi","swagger"],"latest_commit_sha":null,"homepage":"http://supermodel.io","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/supermodel.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}},"created_at":"2016-12-09T18:52:56.000Z","updated_at":"2023-01-28T16:59:57.000Z","dependencies_parsed_at":"2022-08-29T17:00:43.906Z","dependency_job_id":null,"html_url":"https://github.com/supermodel/supermodel-cli","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supermodel%2Fsupermodel-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supermodel%2Fsupermodel-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supermodel%2Fsupermodel-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supermodel%2Fsupermodel-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/supermodel","download_url":"https://codeload.github.com/supermodel/supermodel-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245158833,"owners_count":20570268,"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":["avro","avro-schema","graphql","json","json-ld","json-schema","openapi","swagger"],"created_at":"2024-07-31T07:01:08.675Z","updated_at":"2025-03-23T19:33:20.791Z","avatar_url":"https://github.com/supermodel.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Supermodel CLI\n\n## ⚠️ This repository is deprecated ️️⚠️\n\nMoved to monorepo [supermodel/supermodel](https://github.com/supermodel/supermodel). We decided to switch from single repo per package to monorepo which allow us to have same tooling across all our codebase and deliver features and fixes faster.\n\n[\u003cimg src=\"supermodel.svg\" width=\"200\"\u003e](http://supermodel.io)\n\nThe Supermodel CLI is used to manage and work with JSON Schema YAML models from the command line.\n\nFor more information about Supermodel visit \u003chttps://supermodel.io\u003e.\n\n## Overview\n[![CircleCI](https://circleci.com/gh/supermodel/supermodel-cli.svg?style=svg)](https://circleci.com/gh/supermodel/supermodel-cli)\n\nSupermodel JSON Schema models are JSON schemas files written in YAML format. By convention on YAML file represents one model.\nIt is also customary for all Supermodel models to include a model id (JSON Schema `$id` field). See [Supermodel JSON Schema Model](#supermodel-json-schema-model) for more details.\n\nModels can be freely arranged in the directory structure under the `supermodel` (precisely `supermodel/\u003cusername\u003e`) directory. It is recommended that the directory structure reflects the application domains and subdomains to further ease the organization of models.\n\n\u003cimg src=\"exampleDiagram.png\"\u003e\n\nThe Supermodel CLI then facilitates the creation of these models as well as working with them. Refer to [Usage Examples](#usage-examples) for some examples of how can be the Supermodel CLI used.\n\n## Installation\n\n```bash\n$ npm i -g @supermodel/cli\n```\n\nor\n\n```bash\n$ yarn global add @supermodel/cli\n```\n\n## Getting Started\nAfter the installation, login into the [Supermodel.io](http://supermodel.io):\n\n```bash\n$ supermodel login\n--\u003e Logged as 'username'\n```\n\nYour account is need for two reasons. First, to make your model identifiers globally unique and second, to enable publishing your models at [Supermodel.io](http://supermodel.io). If you haven't created an account at [Supermodel.io](http://supermodel.io) you can do so from the command line using the `supermodel signup` command.\n\n\nWhen you are logged in, initialize the current directory and create your first model:\n\n```bash\n$ supermodel init MyApp\n--\u003e Created ./supermodel/\u003cusername\u003e/MyApp\n```\n\nThe first parameter (`MyApp`) of the `init` command should represent your application, team or domain. This, together with your Supermodel user name will be used as the base path for all the model identifiers created in the initialized supermodel directory.\n\nAfter you have initialized the supermodel directory, step into it:\n\n```bash\n$ cd ./supermodel/\u003cusername\u003e/MyApp\n```\n\nAnd go ahead and create your first model:\n\n```bash\n$ supermodel model create MyModel\n--\u003e Created model 'MyModel' as MyModel.yaml\n```\n\n```bash\n$ open MyModel.yaml\n```\n\nYou can open `MyModel.yaml` in an editor and edit it as necessary. When you are ready to create your next models simply use the `supermodel model create \u003cname\u003e` command again. You can also nest models in directories as long as they are nested under the initial `supermodel/\u003cusername\u003e` directory.\n\nRefer to [Supermodel JSON Schema Model](#supermodel-json-schema-model) for more details about the Supermodel Model or learn about some [usage examples](#usage-examples)\n\n## JSON Schema Functionality\n\nThis CLI tool currently supports the following JSON schema operations:\n\n- **YAML to JSON Conversion**\n\n    Converts JSON Schema in YAML format to JSON format\n\n    ```bash\n    $ supermodel schema json \u003cmodelPath\u003e\n    ```\n\n- **JSON Schema Validation**\n\n    Validates JSON Schema meta schema (read: validates that your JSON Schema is valid)\n\n    ```bash\n    $ supermodel schema validate \u003cpath\u003e\n    ```\n\n- **JSON Schema Compilation**\n\n    Compiles multiple Supermodel JSON Schema model files into one\n\n    ```bash\n    $ supermodel schema compile \u003cdir\u003e\n    ```\n\n- **Resolve JSON Schema References**\n\n    Resolves all remote `$ref`s in a Supermodel JSON Schema model file, transcluding the referenced definitions in the output schema file\n\n    ```bash\n    $ supermodel schema resolve \u003cmodelPath\u003e\n    ```\n\n- **Conversion to OpenAPI Specification 2.0**\n\n    Converts Supermodel JSON Schema model to [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) definitions object\n\n    ```bash\n    $ supermodel schema oas2 \u003cmodelPath\u003e\n    ```\n\n- **Conversion to GraphQL schema**\n\n    Converts Supermodel JSON Schema model to [GraphQL](https://graphql.org/) schema\n\n    ```bash\n    $ supermodel schema graphql \u003cmodelPath\u003e\n    ```\n\n## Usage Examples\n\n### Validate Data Models in CI/CD Pipeline\n\nSupermodel CLI is a CI/CD compliant CLI tool, that is it's `schema validate` command can be used as a part of CI testing, to validate the data models against its meta schema\n\n```bash\n$ supermodel schema validate \u003cpath\u003e\n$ echo $?\n0\n```\n\n### Convert Data Models into Self-contained OpenAPI Spec 2.0\n\nConverts a model or set of models (via `supermodel schema compile`) if `\u003cpath\u003e` is a directory into OAS2 definitions. If the `-o` parameter is provided it replaces the definitions section in the existing OAS2 document.\n\n```bash\n$ supermodel schema oas2 \u003cpathToModel(s)\u003e -o \u003cpathToOAS2\u003e\n```\n\n## Supermodel JSON Schema Model\n\nA Supermodel model (hereafter just \"model\") is a plain [JSON Schema (draft 7)](http://json-schema.org/specification.html) schema file in YAML format. It is customary that Supermodel model contains a top-level type definition, its title and it starts with the model (`$id`).\n\nAt minimum a Supermodel model file looks like:\n\n```yaml\n$id: http://supermodel.io/username/MyModel\n\ntitle: My Model\ntype: object\n```\n\nA Supermodel model might reference another model as defined in [JSON Schema references with `$ref`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8):\n\n\n```yaml\n$id: http://supermodel.io/username/MyModel\n\ntitle: My Model\ntype: object\n\nproperties:\n  modelProperty:\n    $ref: http://supermodel.io/username/AnotherModel\n```\n\nIf the referenced model `http://supermodel.io/username/AnotherModel` shares the same URI base with the `$id` of the referencing model (in this case `http://supermodel.io/username/MyModel`) a relative identifier might be used:\n\n```yaml\n$id: http://supermodel.io/username/MyModel\n\ntitle: My Model\ntype: object\n\nproperties:\n  modelProperty:\n    $ref: AnotherModel\n```\n\nSee [JSON Schema specification](http://json-schema.org/specification.html) for more about JSON Schema references and JSON pointer.\n\n## Developing Supermodel CLI\n\nAfter cloning this repository you can either:\n\n1. copy .env.development into .env `cp ./.env.development ./.env` and change variables for your needs\n2. symlink `ln ./.env.development ./.env`\n\n## Npm publish\n\n```bash\n$ npm publish --access public\n```\n\n## A Good API Project\n\nsupermodel.io (http://supermodel.io), and supermodel CLI (https://github.com/supermodel/supermodel-cli) are Good API (http://goodapi.co) non-profit projects, aimed at promoting modern, reusable, and sustainable data modeling.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupermodel%2Fsupermodel-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsupermodel%2Fsupermodel-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupermodel%2Fsupermodel-cli/lists"}