Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 1019 Bytes

json-injector.md

File metadata and controls

53 lines (45 loc) · 1019 Bytes

JSON Injector

While the HAR injector is already building upon a JSON-based format, the JSON injector also follows this way, however, with a more generic (and easier to write / maintain) format.

A JSON file is defined via the following type:

type KrasJsonFile = Array<{
  request: {
    url: string;
    target: string;
    query: {
      [key: string]: string;
    };
    method: string;
    headers: {
      [key: string]: string;
    };
    content: string;
  };
  response: OneOrMore<{
    headers: {
      [key: string]: string;
    };
    status: {
      code: number;
      text?: string;
    };
    url: string;
    redirectUrl?: string;
    content: string;
  }>;
}>

where

type OneOrMore<T> = T | Array<T>;

The injector specific configuration can be specified as follows:

interface JsonInjectorConfiguration {
  active?: boolean;
  directory?: string;
  generator?: boolean;
  generatorLocaleName?: string;
}

At the moment there are no unique settings for this injector.