UNPKG

request-mocking-protocol

Version:
23 lines 859 B
"use strict"; /** * Schema to generate the response. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.buildMockResponseSchema = buildMockResponseSchema; exports.toMockResponseSchemaObject = toMockResponseSchemaObject; function buildMockResponseSchema(init) { const initObj = toMockResponseSchemaObject(init); assertSchema(initObj); return Object.assign({}, initObj); } function toMockResponseSchemaObject(init) { return typeof init === 'number' ? { status: init } : init; } function assertSchema(schema) { const isStaticResponse = schema.status || schema.body; const isPatchedResponse = schema.request || schema.bodyPatch; if (isStaticResponse && isPatchedResponse) { throw new Error('Ambiguous schema: is it static mock or patched response?'); } } //# sourceMappingURL=response-schema.js.map