Freigeben über


devproxyrc

Standardmäßige Dev Proxy-Konfigurationsdatei.

Dev Proxy unterstützt sowohl JSON(.json) als auch YAML(.yaml, .yml) Formate für Konfigurationsdateien. Die Standarddatei ist devproxyrc.json, aber Dev Proxy erkennt und automatisch erkennt devproxyrc.yaml und devproxyrc.yml.

Hinweis

Die Schemaüberprüfung (validateSchemas) gilt nur für JSON-basierte Konfigurationsdateien. YAML-Konfigurationsdateien werden zur Laufzeit nicht anhand von Schemas überprüft.

Datei: devproxyrc.json

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/rc.schema.json",
  "plugins": [
    {
      "name": "RetryAfterPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll"
    },
    {
      "name": "GenericRandomErrorPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "genericRandomErrorPlugin"
    }
  ],
  "urlsToWatch": [
    "https://jsonplaceholder.typicode.com/*"
  ],
  "genericRandomErrorPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/genericrandomerrorplugin.schema.json",
    "errorsFile": "devproxy-errors.json",
    "rate": 50
  },
  "logLevel": "information",
  "newVersionNotification": "stable",
  "showSkipMessages": true,
  "showTimestamps": true,
  "validateSchemas": true
}

Datei: devproxyrc.yaml (entsprechende YAML-Konfiguration)

plugins:
  - name: RetryAfterPlugin
    enabled: true
    pluginPath: "~appFolder/plugins/DevProxy.Plugins.dll"
  - name: GenericRandomErrorPlugin
    enabled: true
    pluginPath: "~appFolder/plugins/DevProxy.Plugins.dll"
    configSection: genericRandomErrorPlugin

urlsToWatch:
  - "https://jsonplaceholder.typicode.com/*"

genericRandomErrorPlugin:
  errorsFile: devproxy-errors.json
  rate: 50

logLevel: information
newVersionNotification: stable
showSkipMessages: true
showTimestamps: true
validateSchemas: true

Die YAML-Konfiguration unterstützt Anker und Zusammenführungsschlüssel für wiederverwendbare Konfigurationsblöcke:

definitions:
  throttled: &throttled
    statusCode: 429
    body: '{"error": "Too many requests"}'

mocks:
  - request:
      url: https://api.example.com/users
    response:
      <<: *throttled
  - request:
      url: https://api.example.com/groups
    response:
      <<: *throttled