Freigeben über


devproxyrc

Standardmäßige Dev Proxy-Konfigurationsdatei.

Dev Proxy unterstützt sowohl JSON() als auch YAML(, ) Formate für Konfigurationsdateien. Die Standarddatei ist , aber Dev Proxy auch AutoErmittlungen und .

Hinweis

Die Schemaüberprüfung () 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.2.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.2.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:

# Define reusable response templates using YAML anchors
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