{"id":43925912,"url":"https://github.com/khalic-lab/schmock","last_synced_at":"2026-06-14T03:00:47.754Z","repository":{"id":306773749,"uuid":"1027126681","full_name":"khalic-lab/schmock","owner":"khalic-lab","description":"Schema Mocking Made Easy","archived":false,"fork":false,"pushed_at":"2026-05-30T16:56:29.000Z","size":2764,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2026-05-30T18:08:45.944Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/khalic-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":"AUDIT.md","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-27T11:21:55.000Z","updated_at":"2026-05-30T16:50:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"d12f80e5-4622-48d9-87cd-fc7c287f6fda","html_url":"https://github.com/khalic-lab/schmock","commit_stats":null,"previous_names":["khalic-lab/schmock"],"tags_count":75,"template":false,"template_full_name":"ghoullier/bun-typescript-template","purl":"pkg:github/khalic-lab/schmock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalic-lab%2Fschmock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalic-lab%2Fschmock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalic-lab%2Fschmock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalic-lab%2Fschmock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khalic-lab","download_url":"https://codeload.github.com/khalic-lab/schmock/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khalic-lab%2Fschmock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34307685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-02-06T23:06:48.994Z","updated_at":"2026-06-14T03:00:47.748Z","avatar_url":"https://github.com/khalic-lab.png","language":"TypeScript","funding_links":[],"categories":["Testing"],"sub_categories":["Helpers"],"readme":"# Schmock\n\nMock APIs from OpenAPI specs or hand-crafted routes. Callable API, plugin pipeline, framework adapters.\n\n```typescript\nimport { schmock } from '@schmock/core'\nimport { openapi } from '@schmock/openapi'\n\nconst mock = schmock({ state: {} })\n\nmock.pipe(await openapi({\n  spec: './petstore.yaml',\n  seed: { pets: { count: 5 } }\n}))\n\nconst res = await mock.handle('GET', '/pets')\n// → { status: 200, body: [{ petId: 1, name: \"Rex\", ... }, ...] }\n```\n\n## Why Schmock?\n\n- **OpenAPI-first**: Point at a spec, get a fully functional CRUD mock with stateful collections, seed data, security validation, and content negotiation\n- **Callable API**: No HTTP server needed — call `mock.handle()` directly in tests\n- **Plugin pipeline**: Chain plugins with `.pipe()` for validation, pagination, filtering, or custom logic\n- **Framework adapters**: Drop into Express middleware or Angular HTTP interceptor\n- **Smart data generation**: Field-name-aware faker generates realistic data from schemas\n\n## Packages\n\n| Package | Description |\n|---------|-------------|\n| [`@schmock/core`](./docs/getting-started.md) | Core mock builder, routing, and plugin pipeline |\n| [`@schmock/openapi`](./docs/openapi.md) | Auto-register routes from OpenAPI/Swagger specs |\n| [`@schmock/faker`](./docs/api.md#faker-plugin) | Faker-powered automatic data generation |\n| [`@schmock/validation`](./docs/api.md#validation-plugin) | Request/response validation via AJV |\n| [`@schmock/query`](./docs/api.md#query-plugin) | Pagination, sorting, and filtering |\n| [`@schmock/express`](./docs/express.md) | Express middleware adapter |\n| [`@schmock/angular`](./docs/angular.md) | Angular HTTP interceptor adapter |\n| [`@schmock/cli`](./docs/cli.md) | Standalone CLI mock server |\n\n## Quick Start\n\n```sh\nnpm install @schmock/core\n```\n\n### Define routes, call them directly\n\n```typescript\nconst mock = schmock()\n\nmock('GET /users', [\n  { id: 1, name: 'Alice' },\n  { id: 2, name: 'Bob' },\n])\n\nmock('GET /users/:id', ({ params }) =\u003e {\n  const users = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]\n  return users.find(u =\u003e u.id === Number(params.id)) || [404, { error: 'Not found' }]\n})\n\nconst res = await mock.handle('GET', '/users/1')\n// → { status: 200, body: { id: 1, name: 'Alice' }, headers: {...} }\n```\n\n### Stateful mocks with CRUD\n\n```typescript\nconst mock = schmock({ state: { items: [] } })\n\nmock('POST /items', ({ body, state }) =\u003e {\n  const item = { id: state.items.length + 1, ...body }\n  state.items.push(item)\n  return [201, item]\n})\n\nmock('GET /items', ({ state }) =\u003e state.items)\n\nawait mock.handle('POST', '/items', { body: { name: 'Widget' } })\nconst list = await mock.handle('GET', '/items')\n// list.body → [{ id: 1, name: 'Widget' }]\n```\n\n### Mock from an OpenAPI spec\n\n```typescript\nimport { openapi } from '@schmock/openapi'\n\nconst mock = schmock({ state: {} })\nmock.pipe(await openapi({\n  spec: './petstore.yaml',\n  seed: { pets: [{ petId: 1, name: 'Rex', tag: 'dog' }] },\n  security: true,\n}))\n\nawait mock.handle('GET', '/pets')           // list\nawait mock.handle('GET', '/pets/1')         // get by id\nawait mock.handle('POST', '/pets', {        // create\n  body: { name: 'Buddy', tag: 'dog' },\n  headers: { authorization: 'Bearer token' },\n})\nawait mock.handle('DELETE', '/pets/1')      // delete\n```\n\n### Request spying\n\n```typescript\nawait mock.handle('POST', '/items', { body: { name: 'A' } })\nawait mock.handle('POST', '/items', { body: { name: 'B' } })\n\nmock.called('POST', '/items')       // true\nmock.callCount('POST', '/items')    // 2\nmock.lastRequest('POST', '/items')  // { body: { name: 'B' }, ... }\n```\n\n### Plugin pipeline\n\n```typescript\nimport { validationPlugin } from '@schmock/validation'\nimport { queryPlugin } from '@schmock/query'\n\nmock('GET /users', ({ state }) =\u003e state.users)\n  .pipe(validationPlugin({ request: { query: querySchema } }))\n  .pipe(queryPlugin({\n    pagination: { defaultLimit: 20 },\n    sorting: { allowed: ['name', 'created_at'] },\n    filtering: { allowed: ['role'] },\n  }))\n\n// GET /users?filter[role]=admin\u0026sort=name\u0026page=2\u0026limit=10\n```\n\n### Framework adapters\n\n**Express:**\n```typescript\nimport { toExpress } from '@schmock/express'\napp.use('/api', toExpress(mock))\n```\n\n**Angular:**\n```typescript\nimport { provideSchmockInterceptor } from '@schmock/angular'\nproviders: [provideSchmockInterceptor(mock, { baseUrl: '/api' })]\n```\n\n### CLI server\n\n```sh\nnpm install -g @schmock/cli\nschmock petstore.yaml --port 8080 --cors --seed seed.json\n```\n\n## Documentation\n\n| Guide | Description |\n|-------|-------------|\n| [Getting Started](./docs/getting-started.md) | Installation, core concepts, first mock |\n| [OpenAPI](./docs/openapi.md) | Auto-mocking, CRUD, seed data, Prefer header, security, schema patching |\n| [Testing](./docs/testing.md) | Unit tests, integration tests, Angular \u0026 Express testing patterns |\n| [Express Adapter](./docs/express.md) | Express middleware setup and options |\n| [Angular Adapter](./docs/angular.md) | Angular interceptor, helpers, TestBed setup |\n| [CLI](./docs/cli.md) | Command-line mock server |\n| [Plugin Development](./docs/plugins.md) | Writing custom plugins |\n| [API Reference](./docs/api.md) | Complete type and method reference |\n| [Debug Mode](./docs/debug-mode.md) | Request lifecycle logging |\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and workflow.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhalic-lab%2Fschmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhalic-lab%2Fschmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhalic-lab%2Fschmock/lists"}