From 93948855cdc3ad06f7b6ed2f1e016d9785913502 Mon Sep 17 00:00:00 2001
From: waldekmastykarz <waldek@mastykarz.nl>
Date: Fri, 8 Dec 2023 12:55:32 +0100
Subject: [PATCH] Adds JSON schema

---
 dev-proxy/devproxyrc.json          |  1 +
 dev-proxy/responses.json           |  1 +
 dev-proxy/responses.sample.json    |  1 +
 schemas/v1.0/rc.schema.json        | 80 ++++++++++++++++++++++++++++++
 schemas/v1.0/responses.schema.json | 40 +++++++++++++++
 5 files changed, 123 insertions(+)
 create mode 100644 schemas/v1.0/rc.schema.json
 create mode 100644 schemas/v1.0/responses.schema.json

diff --git a/dev-proxy/devproxyrc.json b/dev-proxy/devproxyrc.json
index 568aa8d9..ebd28533 100644
--- a/dev-proxy/devproxyrc.json
+++ b/dev-proxy/devproxyrc.json
@@ -1,4 +1,5 @@
 {
+  "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/rc.schema.json",
   "plugins": [
     {
       "name": "DevToolsPlugin",
diff --git a/dev-proxy/responses.json b/dev-proxy/responses.json
index 9e0eae85..1a535bfd 100644
--- a/dev-proxy/responses.json
+++ b/dev-proxy/responses.json
@@ -1,3 +1,4 @@
 {
+  "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/responses.schema.json",
   "responses": []
 }
\ No newline at end of file
diff --git a/dev-proxy/responses.sample.json b/dev-proxy/responses.sample.json
index f81fe299..082255f8 100644
--- a/dev-proxy/responses.sample.json
+++ b/dev-proxy/responses.sample.json
@@ -1,4 +1,5 @@
 {
+  "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/responses.schema.json",
   "responses": [
     {
       "url": "https://graph.microsoft.com/v1.0/me?*",
diff --git a/schemas/v1.0/rc.schema.json b/schemas/v1.0/rc.schema.json
new file mode 100644
index 00000000..f7f48fd4
--- /dev/null
+++ b/schemas/v1.0/rc.schema.json
@@ -0,0 +1,80 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "title": "Dev Proxy config",
+  "description": "Configuration for Dev Proxy",
+  "type": "object",
+  "properties": {
+    "ipAddress": {
+      "type": "string",
+      "format": "ipv4"
+    },
+    "labelMode": {
+      "type": "string",
+      "enum": ["debug", "text", "icon", "nerdFont"]
+    },
+    "logLevel": {
+      "type": "string",
+      "enum": ["debug", "info", "warn", "error"]
+    },
+    "plugins": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "properties": {
+          "name": {
+            "type": "string"
+          },
+          "enabled": {
+            "type": "boolean"
+          },
+          "pluginPath": {
+            "type": "string"
+          },
+          "configSection": {
+            "type": "string"
+          },
+          "urlsToWatch": {
+            "type": "array",
+            "items": {
+              "type": "string"
+            }
+          }
+        },
+        "required": ["name", "enabled", "pluginPath"]
+      }
+    },
+    "port": {
+      "type": "number",
+      "minimum": 0,
+      "maximum": 65535
+    },
+    "rate": {
+      "type": "number",
+      "minimum": 0,
+      "maximum": 100
+    },
+    "record": {
+      "type": "boolean"
+    },
+    "urlsToWatch": {
+      "type": "array",
+      "items": {
+        "type": "string"
+      }
+    },
+    "watchPids": {
+      "type": "array",
+      "items": {
+        "type": "number"
+      }
+    },
+    "watchProcessNames": {
+      "type": "array",
+      "items": {
+        "type": "string"
+      }
+    }
+  },
+  "additionalProperties": true,
+  "required": ["plugins"]
+}
\ No newline at end of file
diff --git a/schemas/v1.0/responses.schema.json b/schemas/v1.0/responses.schema.json
new file mode 100644
index 00000000..60674c0e
--- /dev/null
+++ b/schemas/v1.0/responses.schema.json
@@ -0,0 +1,40 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "title": "Dev Proxy responses",
+  "description": "Responses for Dev Proxy",
+  "type": "object",
+  "properties": {
+    "responses": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "properties": {
+          "url": {
+            "type": "string"
+          },
+          "method": {
+            "type": "string",
+            "enum": ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"]
+          },
+          "nth": {
+            "type": "integer"
+          },
+          "responseBody": {
+            "type": ["object", "string"]
+          },
+          "responseCode": {
+            "type": "integer"
+          },
+          "responseHeaders": {
+            "type": "object",
+            "additionalProperties": {
+              "type": "string"
+            }
+          }
+        },
+        "required": ["url"]
+      }
+    }
+  },
+  "required": ["responses"]
+}
\ No newline at end of file