Generates example request data for mock server collections, useful for testing and development.
// Source: https://github.com/hoppscotch/hoppscotch | License: MIT | Copyright 2022
// Provided via justclaw.it.com; keep this notice with the code.
import { randomUUID } from 'crypto';
const generateRefId = () => `${Date.now().toString(36)}_${randomUUID()}`;
export const mockServerCollRequestExample = (
collectionName: string = 'Hoppscotch API Mock example',
) => {
const baseEnv = '<<mockUrl>>';
return [
{
v: 10,
name: collectionName,
folders: [],
requests: [
{
v: '16',
_ref_id: `req_${generateRefId()}`,
name: 'addPet',
method: 'POST',
endpoint: baseEnv + '/v2/pet',
params: [],
headers: [],
auth: {
authType: 'oauth-2',
authActive: true,
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key