{"id":21717259,"url":"https://github.com/jormaechea/open-api-mocker","last_synced_at":"2025-10-19T12:23:22.478Z","repository":{"id":41142768,"uuid":"193262126","full_name":"jormaechea/open-api-mocker","owner":"jormaechea","description":"A mock server based in OpenAPI Specification","archived":false,"fork":false,"pushed_at":"2023-11-30T07:34:30.000Z","size":1287,"stargazers_count":122,"open_issues_count":14,"forks_count":34,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T19:02:11.471Z","etag":null,"topics":["api","api-mocker","docker","mock","mock-server","mocking","openapi","schema","schemas"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/open-api-mocker","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/jormaechea.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-06-22T17:38:08.000Z","updated_at":"2025-03-28T18:52:08.000Z","dependencies_parsed_at":"2024-06-18T15:32:23.102Z","dependency_job_id":"a329407e-bac4-4975-93b3-7e3c3e8e8dbf","html_url":"https://github.com/jormaechea/open-api-mocker","commit_stats":{"total_commits":241,"total_committers":12,"mean_commits":"20.083333333333332","dds":"0.18672199170124482","last_synced_commit":"6db0f6e0f031313b3272926ced455ef029221bdd"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jormaechea%2Fopen-api-mocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jormaechea%2Fopen-api-mocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jormaechea%2Fopen-api-mocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jormaechea%2Fopen-api-mocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jormaechea","download_url":"https://codeload.github.com/jormaechea/open-api-mocker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393568,"owners_count":20931812,"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","api-mocker","docker","mock","mock-server","mocking","openapi","schema","schemas"],"created_at":"2024-11-26T01:15:50.355Z","updated_at":"2025-10-19T12:23:17.422Z","avatar_url":"https://github.com/jormaechea.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI Mocker\n\n![Build Status](https://github.com/jormaechea/open-api-mocker/workflows/build/badge.svg)\n[![npm version](https://badge.fury.io/js/open-api-mocker.svg)](https://www.npmjs.com/package/open-api-mocker)\n[![Maintainability](https://api.codeclimate.com/v1/badges/79f6eca7ea3f8fe554c2/maintainability)](https://codeclimate.com/github/jormaechea/open-api-mocker/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/79f6eca7ea3f8fe554c2/test_coverage)](https://codeclimate.com/github/jormaechea/open-api-mocker/test_coverage)\n[![Docker compatible](https://img.shields.io/badge/docker-compatible-green)](https://hub.docker.com/repository/docker/jormaechea/open-api-mocker)\n\nAn API mocker based in the OpenAPI 3.0 specification.\n\n## Installation and usage\n\n### Using npm\n\n```\nnpm i -g open-api-mocker\n\nopen-api-mocker -s my-schema.json -w\n\nopen-api-mocker --help # To prompt every available setting.\n```\n\n### Using docker\n\n```\ndocker run -v \"$PWD/myschema.json:/app/schema.json\" -p \"5000:5000\" jormaechea/open-api-mocker\n```\n\nOr to run an specific version\n\n```\ndocker run -v \"$PWD/myschema.json:/app/schema.json\" -p \"5000:5000\" jormaechea/open-api-mocker:X.Y.Z`\n```\n\nYou can set any parameter when running inside a docker container\n\n```\ndocker run -v \"$PWD/myschema.json:/app/schema.json\" -p \"3000:3000\" jormaechea/open-api-mocker:X.Y.Z -s /app/schema.json -p 3000`\n```\n\n## Capabilities\n\n- [x] Read yaml and json OpenAPI v3 schemas.\n- [x] Port binding selection\n- [x] Request parameters validation\n- [x] Request body validation\n- [x] Response body and headers generation based on examples or schemas\n- [x] Response selection using request header: `Prefer: statusCode=XXX` or `Prefer: example=name`\n- [x] Request and response logging\n- [x] Servers basepath support\n- [x] Support x-faker and x-count extension methods to customise generated responses\n- [ ] API Authentication\n\n## Customizing Generated Responses\nThe OpenAPI specification allows custom properties to be added to an API definition in the form of _x-*_.\nOpenAPI Mocker supports the use of two custom extensions to allow data to be randomised which should allow for more\nrealistic looking data when developing a UI against a mock API for instance.\n\n### x-faker\nThe _x-faker_ extension is valid for use on properties that have a primitive type (e.g. `string`/`integer`, etc.)\nand can be used within an API definition to use one or more methods from the community mantained\n[Faker](https://fakerjs.dev/) library for generating random data.\n\nGiven the following API definition:\n```yaml\nopenapi: '3.0.2'\ninfo:\n  title: Cats\n  version: '1.0'\nservers:\n  - url: https://api.cats.test/v1\npaths:\n  /cat:\n    get:\n      responses:\n        '200':\n          description: OK\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  firstName:\n                    type: string\n                    x-faker: person.firstName\n                  lastName:\n                    type: string\n                    x-faker: person.lastName\n                  fullName:\n                    type: string\n                    x-faker: '{{person.firstName}} {{person.lastName}}'\n                  age:\n                    type: string\n                    x-faker: 'number.int({ \"min\": 1, \"max\": 20 })'\n\n```\n\nA JSON response similar to the following would be produced:\n```JSON\n{\n    \"firstName\": \"Ted\",\n    \"lastName\": \"Kozey\",\n    \"fullName\": \"Herbert Lowe\",\n    \"age\": 12\n}\n```\n\nThe _x-faker_ extension accepts values in 3 forms:\n1. _fakerNamespace.method_. e.g. `string.uuid`\n2. _fakerNamespace.method({ \"methodArgs\": \"in\", \"json\": \"format\" })_. e.g. `number.int({ \"max\": 100 })`\n3. A mustache template string making use of the 2 forms above. e.g. `My name is {{person.firstName}} {{person.lastName}}`\n\n*NOTE*: To avoid new fake data from being generated on every call, up to 10 responses per endpoint are cached\nbased on the incoming query string, request body and headers.\n\n### x-count\nThe _x-count_ extension has effect only when used on an `array` type property.\nIf encountered, OpenAPI Mocker will return an array with the given number of elements instead of the default of an\narray with a single item.\n\nFor example, the following API definition:\n```yaml\nopenapi: '3.0.2'\ninfo:\n  title: Cats\n  version: '1.0'\nservers:\n  - url: https://api.cats.test/v1\npaths:\n  /cat:\n    get:\n      responses:\n        '200':\n          description: OK\n          content:\n            application/json:\n              schema:\n                type: array\n                x-count: 5\n                items:\n                  type: string\n```\n\nWill produce the following response:\n```JSON\n[\n    \"string\",\n    \"string\",\n    \"string\",\n    \"string\",\n    \"string\"\n]\n```\n\n## Advanced usage\n\nSee the [advanced usage docs](docs/README.md) to extend or build your own app upon OpenAPI Mocker.\n\n## Tests\n\nSimply run `npm t`\n\n## Contributing\n\nIssues and PRs are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjormaechea%2Fopen-api-mocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjormaechea%2Fopen-api-mocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjormaechea%2Fopen-api-mocker/lists"}