TypeScript/JavaScript SDK for programmatic interaction with the OASMock server via its HTTP API.
npm install oasmock-sdkimport { MockSDK } from 'oasmock-sdk'
const mockSDK = new MockSDK('http://localhost:19191')
// One‑time mocking of a response
await mockSDK.onRequest('/some/url', 'POST').respondWithOnce({
body: { some: 'data' }
})
// Mocking with additional conditions
await mockSDK.onRequest('/some/url')
.withCookies({ uid: '1' })
.withHeaders({ authorization: 'Bearer token' })
.withSearchParams({ test: 'value' })
.respondWith({
body: {}
})
// Retrieve request history
const lastRequest = await mockSDK.getLastRequest({
path: '/some/url',
method: 'POST'
})See docs/api.md for the full MockSDK / MockSDKRequest reference, type definitions, and error handling.
npm run buildnpm testnpm run lint
npm run formatnpm run typecheckPublishing is tag-driven: the git tag is the single source of truth for the npm version.
- Create and push a
vX.Y.Ztag (e.g.v0.0.7):git tag v0.0.7 && git push origin v0.0.7 - The publish workflow derives the version from the tag, validates it as semver, and publishes
oasmock-sdk@X.Y.Zto npm.
The version committed in package.json is not the publish authority — the tag always wins.
MIT