{"id":25765480,"url":"https://github.com/yayoc/swagger-to-mock","last_synced_at":"2025-02-26T22:19:33.651Z","repository":{"id":32633481,"uuid":"138289588","full_name":"yayoc/swagger-to-mock","owner":"yayoc","description":"Mock data generator CLI for Swagger3 (OpenAPI 3)","archived":false,"fork":false,"pushed_at":"2023-01-04T06:19:20.000Z","size":1533,"stargazers_count":53,"open_issues_count":15,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T22:54:07.256Z","etag":null,"topics":["cli","mock","openapi3","swagger"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/swagger-to-mock","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yayoc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-22T10:26:57.000Z","updated_at":"2024-07-26T07:20:03.000Z","dependencies_parsed_at":"2023-01-14T21:47:02.734Z","dependency_job_id":null,"html_url":"https://github.com/yayoc/swagger-to-mock","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Fswagger-to-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Fswagger-to-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Fswagger-to-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Fswagger-to-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yayoc","download_url":"https://codeload.github.com/yayoc/swagger-to-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240941850,"owners_count":19882110,"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":["cli","mock","openapi3","swagger"],"created_at":"2025-02-26T22:19:33.098Z","updated_at":"2025-02-26T22:19:33.636Z","avatar_url":"https://github.com/yayoc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swagger-to-mock [![travis-ci](https://travis-ci.org/yayoc/swagger-to-mock.svg?branch=master)](https://travis-ci.org/yayoc/swagger-to-mock) [![Greenkeeper badge](https://badges.greenkeeper.io/yayoc/swagger-to-mock.svg)](https://greenkeeper.io/)\n\nMock data generator CLI for Swagger3 (OpenAPI 3)\n\n## Install\n\n```shell\nnpm i -g swagger-to-mock\n```\n\n## Generate mock data\n\n```shell\nswagger-to-mock \u003cYOUR SWAGGER FILE\u003e\n```\n\nwill generate **JSON file** per each API response.  \nJSON data values should be example values on your swagger if you specified examples.  \nOtherwise, `swagger-to-mock` follows [data type rules](https://github.com/yayoc/swagger-to-mock/#data-type-support) and generate arbitrary values.  \nIf there is no rule like `format`, values should be below.\n\n```yaml\nstring: \"\"\nnumber: 0\ninteger: 0\nboolean: true\narray: []\nobject: {}\n```\n\n## Example\n\nIf we pass [an example YAML file](https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore-expanded.yaml)\n\n```yaml\nresponses:\n  '200':\n    description: pet response\n    content:\n      application/json:\n        schema:\n          type: array\n          items:\n            $ref: '#/components/schemas/Pet'\n```\n\n`swagger-to-mock` will generate file named `pets_get_200.json` and the body should be below\n\n```json\n[\n  {\n    \"name\": \"\",\n    \"tag\": \"\",\n    \"id\": 0\n  }\n]\n```\n\n## File Name\n\nNaming JSON file will follow the format below. \n`${API_PATH}_${HTTP_METHOD}_${RESPONSE_STATUS}.json`\n\n## Data Type Support [In Progress]\n\n`swagger-to-mock` will follow rules based on [OpenAPI 3 specification](https://swagger.io/docs/specification/data-models/data-types/) for each data type, If the example value is not specified.\n\n### Mixed Types\n\nIf you specify `oneOf` or `anyOf`, The value should be at the top type.\n\n### Numbers\n\n- format\n- Minimum and Maximum\n- Multiples\n\n### String\n\n- format\n- pattern\n\n### Boolean\n\nvalue should be `true` or `false`.\n\n### Null\n\n### Arrays\n\n- Mixed-Type Arrays\n- Array Length\n\n### Objects\n\n- Free-Form Object\n\n### Files\n\n### Any Type\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyayoc%2Fswagger-to-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyayoc%2Fswagger-to-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyayoc%2Fswagger-to-mock/lists"}