{"id":13878767,"url":"https://github.com/tuwilof/tomograph","last_synced_at":"2025-05-12T23:29:31.470Z","repository":{"id":46176031,"uuid":"81070217","full_name":"tuwilof/tomograph","owner":"tuwilof","description":"Convert API Blueprint, Swagger and OpenAPI to JSON Schema and search through it","archived":false,"fork":false,"pushed_at":"2024-12-08T11:20:45.000Z","size":454,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-03T11:02:12.166Z","etag":null,"topics":["api-blueprint","cli","converter","drafter","json-schema","openapi","openapi3","swagger"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/tuwilof.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2017-02-06T09:27:24.000Z","updated_at":"2024-12-08T11:20:22.000Z","dependencies_parsed_at":"2024-05-28T00:26:44.528Z","dependency_job_id":"de085edf-ae5b-437e-8587-a49217fdfc94","html_url":"https://github.com/tuwilof/tomograph","commit_stats":null,"previous_names":["matchtechnologies/tomograph"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwilof%2Ftomograph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwilof%2Ftomograph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwilof%2Ftomograph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuwilof%2Ftomograph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuwilof","download_url":"https://codeload.github.com/tuwilof/tomograph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253839741,"owners_count":21972363,"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":["api-blueprint","cli","converter","drafter","json-schema","openapi","openapi3","swagger"],"created_at":"2024-08-06T08:01:59.313Z","updated_at":"2025-05-12T23:29:31.452Z","avatar_url":"https://github.com/tuwilof.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Tomograph \n\nConvert API Blueprint, Swagger and OpenAPI to minimal routes with JSON Schema. For ease of use and creation of new tools.\n\nWill look like\n\n  ```json\n  [\n    {\n      \"path\": \"/sessions\",\n      \"method\": \"POST\",\n      \"content-type\": \"application/json\",\n      \"requests\": [{\n        \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n        \"type\": \"object\",\n        \"properties\": {\n          \"login\": {\n            \"type\": \"string\"\n          },\n          \"password\": {\n            \"type\": \"string\"\n          },\n          \"captcha\": {\n            \"type\": \"string\"\n          }\n        },\n        \"required\": [\n          \"login\",\n          \"password\"\n        ]\n      }],\n      \"responses\": [\n        {\n          \"status\": \"401\",\n          \"content-type\": \"application/json\",\n          \"body\": {}\n        },\n        {\n          \"status\": \"429\",\n          \"content-type\": \"application/json\",\n          \"body\": {}\n        },\n        {\n          \"status\": \"201\",\n          \"content-type\": \"application/json\",\n          \"body\": {\n            \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n            \"type\": \"object\",\n            \"properties\": {\n              \"confirmation\": {\n                \"type\": \"object\",\n                \"properties\": {\n                  \"id\": {\n                    \"type\": \"string\"\n                  },\n                  \"type\": {\n                    \"type\": \"string\"\n                  },\n                  \"operation\": {\n                    \"type\": \"string\"\n                  }\n                },\n                \"required\": [\n                  \"id\",\n                  \"type\",\n                  \"operation\"\n                ]\n              },\n              \"captcha\": {\n                \"type\": \"string\"\n              },\n              \"captcha_does_not_match\": {\n                \"type\": \"boolean\"\n              }\n            }\n          }\n        }\n      ]\n    }\n  ]\n  ```\n\n## Installation\n\nThen add this line to your application's Gemfile:\n\n```ruby\ngem 'tomograph'\n```\n\nAfter that execute:\n\n```bash\n$ bundle\n```\n\nOr install the gem by yourself:\n\n```bash\n$ gem install tomograph\n```\n\n## Usage\n\n### In code\n\n#### OpenAPI 2.0\n\nAlso Swagger\n\n```ruby\nrequire 'tomograph'\n\ntomogram = Tomograph::Tomogram.new(openapi2_json_path: '/path/to/doc.json')\n```\n\n#### OpenAPI 3.0\n\nAlso OpenAPI\n\n```ruby\nrequire 'tomograph'\n\ntomogram = Tomograph::Tomogram.new(openapi3_yaml_path: '/path/to/doc.yaml')\n```\n\n#### API Blueprint\n\nFirst you need to install [drafter](https://github.com/apiaryio/drafter).\nWorks after conversion from API Blueprint to API Elements (in YAML file) with Drafter.\n\nThat is, I mean that you first need to do this\n\n```bash\ndrafter doc.apib -o doc.yaml\n```\n\nand then\n\n```ruby\nrequire 'tomograph'\n\ntomogram = Tomograph::Tomogram.new(drafter_yaml_path: '/path/to/doc.yaml')\n```\n\n#### Tomograph\n\nTo use additional features of the pre-converted\n\n```ruby\nrequire 'tomograph'\n\ntomogram = Tomograph::Tomogram.new(tomogram_json_path: '/path/to/doc.json')\n```\n\n#### prefix\nDefault: `''`\n\nYou can specify API prefix and path to the spec using one of the possible formats:\n\n```ruby\nTomograph::Tomogram.new(prefix: '/api/v2', drafter_yaml_path: '/path/to/doc.yaml')\n```\n\n```ruby\nTomograph::Tomogram.new(prefix: '/api/v2', tomogram_json_path: '/path/to/doc.json')\n```\n\n#### to_json\nUse `to_json` for converting to JSON, example from API Blueprint:\n\n```ruby\ntomogram.to_json\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample input\u003c/summary\u003e\n\n  ```apib\n  FORMAT: 1A\n  HOST: http://test.local\n  \n  # project\n  \n  # Group project\n  \n  Project\n  \n  ## Authentication [/sessions]\n  \n  ### Sign In [POST]\n  \n  + Request (application/json)\n  \n      + Attributes\n       + login (string, required)\n       + password (string, required)\n       + captcha (string, optional)\n  \n  + Response 401 (application/json)\n  \n  + Response 429 (application/json)\n  \n  + Response 201 (application/json)\n  \n      + Attributes\n       + confirmation (Confirmation, optional)\n       + captcha (string, optional)\n       + captcha_does_not_match (boolean, optional)\n  \n  \n  # Data Structures\n  \n  ## Confirmation (object)\n    + id (string, required)\n    + type (string, required)\n    + operation (string, required)\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample output\u003c/summary\u003e\n\n  ```json\n  [\n    {\n      \"path\": \"/sessions\",\n      \"method\": \"POST\",\n      \"content-type\": \"application/json\",\n      \"requests\": [{\n        \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n        \"type\": \"object\",\n        \"properties\": {\n          \"login\": {\n            \"type\": \"string\"\n          },\n          \"password\": {\n            \"type\": \"string\"\n          },\n          \"captcha\": {\n            \"type\": \"string\"\n          }\n        },\n        \"required\": [\n          \"login\",\n          \"password\"\n        ]\n      }],\n      \"responses\": [\n        {\n          \"status\": \"401\",\n          \"content-type\": \"application/json\",\n          \"body\": {}\n        },\n        {\n          \"status\": \"429\",\n          \"content-type\": \"application/json\",\n          \"body\": {}\n        },\n        {\n          \"status\": \"201\",\n          \"content-type\": \"application/json\",\n          \"body\": {\n            \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n            \"type\": \"object\",\n            \"properties\": {\n              \"confirmation\": {\n                \"type\": \"object\",\n                \"properties\": {\n                  \"id\": {\n                    \"type\": \"string\"\n                  },\n                  \"type\": {\n                    \"type\": \"string\"\n                  },\n                  \"operation\": {\n                    \"type\": \"string\"\n                  }\n                },\n                \"required\": [\n                  \"id\",\n                  \"type\",\n                  \"operation\"\n                ]\n              },\n              \"captcha\": {\n                \"type\": \"string\"\n              },\n              \"captcha_does_not_match\": {\n                \"type\": \"boolean\"\n              }\n            }\n          }\n        }\n      ]\n    }\n  ]\n  ```\n\u003c/details\u003e \n\n#### to_a\n```ruby\ntomogram.to_a\n```\n\n#### find_request\n```ruby\nrequest = tomogram.find_request(method: 'GET', path: '/status/1?qwe=rty')\n```\n\n#### find_request_with_content_type\n```ruby\nrequest = tomogram.find_request_with_content_type(method: 'GET', path: '/status/1?qwe=rty', content_type: 'application/json')\n```\n\n#### `find_responses`\n```ruby\nresponses = request.find_responses(status: '200')\n```\n\n#### prefix_match?\nThis may be useful if you specify a prefix.\n\n```ruby\ntomogram.prefix_match?('http://local/api/v2/users')\n```\n\n#### to_resources\nMaps resources for API Blueprint with possible requests.\n\nExample output:\n\n```ruby\n{\n  '/sessions' =\u003e ['POST /sessions']\n}\n```\n\n### Command line tool\n\nCLI allows you to convert files from API Blueprint (API Elements), Swagger and OpenAPI to JSON Schema.\n\nRun CLI with `-h` to get detailed help:\n\n```bash\ntomograph -h\n```\n\nTo specify the handler version use the `-d` flag:\n\n#### OpenAPI 2.0\n```bash\ntomograph -d openapi2 openapi2.json tomogram.json\n```\n\n#### OpenAPI 3.0\n```bash\ntomograph -d openapi3 openapi3.yaml doc.json\n```\n\n#### API Blueprint\n```bash\ntomograph -d 4 apielemetns.yaml doc.json\n```\n\n#### exclude-description\n\nExclude \"description\" keys from json-schemas.\n\n```bash\ntomograph -d 4 apielemetns.yaml doc.json --exclude-description\n```\n\n#### split\n\nSplit output into files by method. Output in dir path.\n\n```bash\ntomograph -d 4 --split apielemetns.yaml jsons/\n```\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n[Sponsored by FunBox](https://funbox.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuwilof%2Ftomograph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuwilof%2Ftomograph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuwilof%2Ftomograph/lists"}