{
  "$id": "http://json-schema.org/draft-04/schema#",
  "title": "JSON schema ASP.NET Core's appsettings.json file",
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "definitions": {
    "NLog": {
      "$id": "#/NLog",
      "type": "object",
      "title": "NLog config",
      "default": {},
      "examples": [
        {
          "NLog": {
            "throwConfigExceptions": true,
            "targets": {
              "logfile": {
                "type": "File",
                "fileName": "c:/temp/nlog-${shortdate}.log"
              },
              "logconsole": {
                "type": "Console"
              }
            },
            "rules": [
              {
                "logger": "*",
                "minLevel": "Info",
                "writeTo": "logconsole"
              },
              {
                "logger": "*",
                "minLevel": "Debug",
                "writeTo": "logfile"
              }
            ]
          }
        }
      ],
      "additionalProperties": true,
      "properties": {
        "autoReload": {
          "$id": "#/NLog/properties/autoReload",
          "type": "boolean",
          "title": "autoReload",
          "description": "Watch for changes and reload automatically when changed.",
          "default": false
        },
        "throwConfigExceptions": {
          "$id": "#/NLog/properties/throwConfigExceptions",
          "type": [
            "boolean",
            "null"
          ],
          "title": "throwConfigExceptions",
          "description": "Throws an exception when there is a config error? If not set, then throwExceptions will be used for this setting.",
          "default": false,
          "examples": [
            true
          ]
        },
        "throwExceptions": {
          "$id": "#/NLog/properties/throwExceptions",
          "type": "boolean",
          "title": "throwExceptions",
          "description": "Throws an exception when there is an error",
          "default": false,
          "examples": [
            true
          ]
        },
        "internalLogLevel": {
          "$id": "#/NLog/properties/internalLogLevel",
          "type": "string",
          "title": "internalLogLevel",
          "description": "The minimal log level for the internal logger.",
          "enum": [
            "Trace",
            "Debug",
            "Info",
            "Warn",
            "Error",
            "Fatal",
            "Off"
          ],
          "default": "Off"
        },
        "internalLogFile": {
          "$id": "#/NLog/properties/internalLogFile",
          "type": "string",
          "title": "internal Log File",
          "description": "Write internal log to a file",
          "examples": [
            "${basedir}/internal-nlog.log",
            "${currentdir}/internal-nlog.log",
            "${tempdir}/internal-nlog.log",
            "${processdir}/internal-nlog.log",
            "%appdata%/internal-nlog.log"
          ]
        },
        "internalLogToConsole": {
          "$id": "#/NLog/properties/internalLogToConsole",
          "type": "boolean",
          "title": "internalLogToConsole",
          "description": "Write internal log to a console",
          "default": "false"
        },
        "internalLogToConsoleError": {
          "$id": "#/NLog/properties/internalLogToConsoleError",
          "type": "boolean",
          "title": "internalLogToConsole",
          "description": "Write internal log to a console with error stream",
          "default": "false"
        },
        "globalThreshold": {
          "$id": "#/NLog/properties/globalThreshold",
          "type": "string",
          "title": "global Threshold",
          "description": "Log events below this threshold are not logged.",
          "enum": [
            "Trace",
            "Debug",
            "Info",
            "Warn",
            "Error",
            "Fatal",
            "Off"
          ],
          "default": "Off"
        },
        "autoShutdown": {
          "$id": "#/NLog/properties/autoShutdown",
          "type": "boolean",
          "title": "autoShutdown",
          "description": "Automatically call `LogFactory.Shutdown` on AppDomain.Unload or AppDomain.ProcessExit",
          "default": "true"
        },
        "extensions": {
          "$id": "#/NLog/properties/extensions",
          "type": "array",
          "title": "extensions",
          "description": "",
          "default": [],
          "examples": [
            [
              {
                "assembly": "NLog.Extensions.Logging"
              },
              {
                "assembly": "NLog.Web.AspNetCore"
              }
            ]
          ],
          "additionalItems": false,
          "items": {
            "$id": "#/NLog/properties/extensions/item",
            "type": "object",
            "title": "property",
            "description": "",
            "default": {},
            "examples": [
              {
                "assembly": "NLog.Extensions.Logging"
              }
            ],
            "additionalProperties": false,
            "properties": {
              "assembly": {
                "$id": "#/NLog/properties/extensions/item/properties/assembly",
                "type": "string",
                "title": "assembly",
                "description": "",
                "examples": [
                  "NLog.Extensions.Logging"
                ]
              },
              "prefix": {
                "$id": "#/NLog/properties/extensions/item/properties/prefix",
                "type": "string",
                "title": "prefix",
                "description": "Item name prefix",
                "default": ""
              },
              "type": {
                "$id": "#/NLog/properties/extensions/item/properties/type",
                "type": "string",
                "title": "type",
                "description": "",
                "default": ""
              },
              "assemblyFile": {
                "$id": "#/NLog/properties/extensions/item/properties/assemblyFile",
                "type": "string",
                "title": "assemblyFile",
                "description": "",
                "default": ""
              }
            }
          }
        },
        "variables": {
          "$id": "#/NLog/properties/variables",
          "type": "object",
          "title": "variables",
          "description": "Key-value pair of variables",
          "examples": [
            {
              "myLogDir": "c:/temp"
            }
          ],
          "additionalProperties": true,
          "propertyNames": {
            "pattern": "^[A-Za-z0-9_.-]+$"
          },
          "patternProperties": {
            ".*": {
              "type": [
                "number",
                "string",
                "boolean"
              ]
            }
          }
        },
        "default-wrapper": {
          "$id": "#/NLog/properties/default-wrapper",
          "type": "object",
          "title": "default-wrapper",
          "description": "",
          "default": {},
          "examples": [
            {
              "type": "AsyncWrapper",
              "overflowAction": "Block"
            }
          ],
          "additionalProperties": true,
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "$id": "#/NLog/properties/default-wrapper/properties/type",
              "type": "string",
              "title": "type",
              "description": "",
              "examples": [
                "AsyncWrapper"
              ]
            }
          }
        },
        "targets": {
          "$id": "#/NLog/properties/targets",
          "type": "object",
          "title": "targets",
          "description": "",
          "default": {},
          "examples": [
            {
              "all-file": {
                "type": "File",
                "fileName": "${var_logdir}/nlog-all-${shortdate}.log",
                "layout": {
                  "type": "JsonLayout",
                  "Attributes": [
                    {
                      "name": "timestamp",
                      "layout": "${date:format=o}"
                    },
                    {
                      "name": "level",
                      "layout": "${level}"
                    },
                    {
                      "name": "logger",
                      "layout": "${logger}"
                    },
                    {
                      "name": "message",
                      "layout": "${message:raw=true}"
                    },
                    {
                      "name": "properties",
                      "encode": false,
                      "layout": {
                        "type": "JsonLayout",
                        "includeallproperties": "true"
                      }
                    }
                  ]
                }
              },
              "own-console": {
                "type": "LimitingWrapper",
                "interval": "00:00:01",
                "messageLimit": 100,
                "target": {
                  "type": "ColoredConsole",
                  "layout": "${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|${callsite}",
                  "rowHighlightingRules": [
                    {
                      "condition": "level == LogLevel.Error",
                      "foregroundColor": "Red"
                    },
                    {
                      "condition": "level == LogLevel.Fatal",
                      "foregroundColor": "Red",
                      "backgroundColor": "White"
                    }
                  ]
                }
              },
              "database": {
                "type": "Database",
                "dbProvider": "System.Data.SqlClient",
                "connectionString": "Data Source=database server;Initial Catalog=database;Trusted_Connection=False;User Id=AppUser;Password=AppUserPassword;",
                "keepConnection": "true",
                "commandText": "insert into dbo.log (Guid, MachineName,Timestamp,Level,Message,Logger,Callsite,Exception) values (@Guid, @MachineName, @Timestamp, @Level, @Message, @Logger, @Callsite, @Exception);",
                "parameters": [
                  {
                    "name": "@Guid",
                    "layout": "${guid}"
                  },
                  {
                    "name": "@MachineName",
                    "layout": "${machinename}"
                  },
                  {
                    "name": "@Timestamp",
                    "layout": "${date:format=o}",
                    "dbType": "DbType.DateTime"
                  },
                  {
                    "name": "@Level",
                    "layout": "${level}"
                  },
                  {
                    "name": "@Message",
                    "layout": "${message}"
                  },
                  {
                    "name": "@Logger",
                    "layout": "${logger}"
                  },
                  {
                    "name": "@Callsite",
                    "layout": "${callsite}"
                  },
                  {
                    "name": "@Exception",
                    "layout": "${exception:tostring}"
                  }
                ]
              }
            }
          ],
          "additionalProperties": true
        },
        "rules": {
          "oneOf": [
            {
              "$id": "#/NLog/properties/rules",
              "type": "array",
              "title": "rules",
              "description": "",
              "default": [],
              "examples": [
                [
                  {
                    "logger": "*",
                    "minLevel": "Trace",
                    "writeTo": "all-file, database"
                  },
                  {
                    "logger": "Microsoft.*",
                    "maxLevel": "Info",
                    "final": true
                  }
                ]
              ],
              "additionalItems": true,
              "items": {
                "$id": "#/NLog/properties/rules/item",
                "type": "object",
                "title": "logger rule",
                "description": "Send events to targets",
                "default": {},
                "examples": [
                  {
                    "logger": "*",
                    "minLevel": "Error",
                    "writeTo": "database"
                  },
                  {
                    "logger": "*",
                    "minLevel": "Trace",
                    "writeTo": "all-file, database",
                    "enabled": "false"
                  },
                  {
                    "logger": "MyNamespace.MyClass",
                    "minLevel": "Trace",
                    "writeTo": "MyClass-file"
                  }
                ],
                "required": [
                  "logger"
                ],
                "additionalProperties": true,
                "properties": {
                  "logger": {
                    "$id": "#/NLog/properties/rules/item/properties/logger",
                    "type": "string",
                    "title": "logger",
                    "description": "Filter on the name of the logger. May include wildcard characters ('*' or '?').",
                    "examples": [
                      "*",
                      "Microsoft.*",
                      "*.Something.*"
                    ]
                  },
                  "ruleName": {
                    "$id": "#/NLog/properties/rules/item/properties/rulename",
                    "type": "string",
                    "title": "rulename",
                    "description": "Rule identifier to allow rule lookup with Configuration.FindRuleByName and Configuration.RemoveRuleByName.",
                    "examples": [
                      "*"
                    ]
                  },
                  "level": {
                    "anyOf": [
                      {
                        "$id": "#/NLog/properties/rules/item/properties/level",
                        "type": "string",
                        "title": "level",
                        "description": "",
                        "enum": [
                          "Trace",
                          "Debug",
                          "Info",
                          "Warn",
                          "Error",
                          "Fatal"
                        ]
                      },
                      {
                        "type": "string",
                        "title": "level"
                      }
                    ]
                  },
                  "levels": {
                    "$id": "#/NLog/properties/rules/item/properties/levels",
                    "type": "string",
                    "title": "levels",
                    "description": "Comma separated list of levels that this rule matches.",
                    "examples": [
                      "Trace, Debug",
                      "Warn, Error, Fatal",
                      "Debug"
                    ]
                  },
                  "minLevel": {
                    "anyOf": [
                      {
                        "$id": "#/NLog/properties/rules/item/properties/minLevel",
                        "type": "string",
                        "title": "minLevel",
                        "description": "",
                        "enum": [
                          "Trace",
                          "Debug",
                          "Info",
                          "Warn",
                          "Error",
                          "Fatal"
                        ]
                      },
                      {
                        "type": "string",
                        "title": "minLevel"
                      }
                    ]
                  },
                  "maxLevel": {
                    "anyOf": [
                      {
                        "$id": "#/NLog/properties/rules/item/properties/maxLevel",
                        "type": "string",
                        "title": "maxLevel",
                        "description": "",
                        "enum": [
                          "Trace",
                          "Debug",
                          "Info",
                          "Warn",
                          "Error",
                          "Fatal"
                        ]
                      },
                      {
                        "type": "string",
                        "title": "maxLevel"
                      }
                    ]
                  },
                  "writeTo": {
                    "$id": "#/NLog/properties/rules/item/properties/writeTo",
                    "type": "string",
                    "title": "writeTo",
                    "description": "Name or names of a target - separated by comma. Remove this property for sending events to the blackhole.",
                    "examples": [
                      "target1",
                      "target1, target2"
                    ]
                  },
                  "final": {
                    "$id": "#/NLog/properties/rules/item/properties/final",
                    "type": "boolean",
                    "title": "final",
                    "description": "Ignore further rules if this one matches.",
                    "default": false,
                    "examples": [
                      true
                    ]
                  },
                  "enabled": {
                    "$id": "#/NLog/properties/rules/item/properties/final",
                    "type": "boolean",
                    "title": "final",
                    "description": "",
                    "default": false,
                    "examples": [
                      true
                    ]
                  },
                  "filters": {
                    "$id": "#/NLog/properties/rules/item/properties/filters",
                    "type": "object",
                    "title": "filters",
                    "description": "",
                    "default": {},
                    "examples": [
                      {
                        "whenRepeated": {
                          "layout": "${message}",
                          "action": "Ignore"
                        }
                      }
                    ],
                    "additionalProperties": true
                  }
                }
              }
            },
            {
              "type": "object",
              "propertyNames": {
                "pattern": "^[0-9]+$"
              },
              "patternProperties": {
                ".*": {
                  "schema": "#/NLog/properties/rules/item"
                }
              },
              "examples": [
                [
                  {
                    "0": {
                      "logger": "*",
                      "minLevel": "Error",
                      "writeTo": "errorFile,errorEmail"
                    },
                    "1": {
                      "logger": "*",
                      "minLevel": "Debug",
                      "writeTo": "debugFile"
                    }
                  }
                ]
              ]
            }
          ]
        }
      }
    },
    "webOptimizer": {
      "type": "object",
      "description": "Settings for WebOptimizer.Core",

      "properties": {
        "enableCaching": {
          "description": "Determines if the \"cache-control\" HTTP headers should be set and if conditional GET (304) requests should be supported. This could be helpful to disable while in development mode.",
          "type": "boolean"
        },
        "enableTagHelperBundling": {
          "description": "Determines if `<script>` and `<link>` elements should point to the bundled path or a reference per source file should be created. This is helpful to disable when in development mode.",
          "type": "boolean",
          "default": true
        }
      }
    },
    "cdn": {
      "type": "object",
      "description": "Definitions for WebEssentials.AspNetCore.CdnTagHelpers",

      "properties": {
        "url": {
          "description": "An absolute URL used as a prefix for static resources",
          "type": "string",
          "pattern": "^((//|https?://).+|)$"
        },
        "prefetch": {
          "description": "If true, injects a <link rel='dns-prefetch'> tag that speeds up DNS resolution to the CDN.",
          "type": "boolean",
          "default": true
        }
      }
    },
    "pwa": {
      "properties": {
        "cacheId": {
          "description": "The cache identifier of the service worker (can be any string). Change this property to force the service worker to reload in browsers.",
          "type": "string",
          "default": "v1.0"
        },
        "offlineRoute": {
          "description": "The route to the page to show when offline.",
          "type": "string",
          "default": "/offline.html"
        },
        "registerServiceWorker": {
          "description": "Determines if a script that registers the service worker should be injected into the bottom of the HTML page.",
          "type": "boolean",
          "default": true
        },
        "registerWebmanifest": {
          "description": "Determines if a meta tag that points to the web manifest should be inserted at the end of the head element.",
          "type": "boolean",
          "default": true
        },
        "routesToPreCache": {
          "description": "A comma separated list of routes to pre-cache when service worker installs in the browser.",
          "type": "string",
          "default": ""
        },
        "strategy": {
          "description": "Selects one of the predefined service worker types.",
          "enum": [ "cacheFirst", "cacheFirstSafe", "minimal", "networkFirst" ],
          "default": "cacheFirstSafe"
        }
      }
    },
    "ElmahIo": {
      "properties": {
        "ApiKey": {
          "description": "An elmah.io API key with the Messages | Write permission.",
          "type": "string",
          "pattern": "^[0-9a-f]{32}$"
        },
        "LogId": {
          "description": "The Id of the elmah.io log to store messages in.",
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "HeartbeatId": {
          "description": "The Id of the elmah.io heartbeat to notify.",
          "type": "string",
          "pattern": "^[0-9a-f]{32}$"
        }
      },
      "required": [ "ApiKey", "LogId" ]
    },
    "MicrosoftExtensionsLoggingLogLevel": {
      "type": "object",
      "properties": {
        "Default": {
          "enum": [ "Trace", "Debug", "Information", "Warning", "Error", "Critical", "None" ]
        }
      }
    },
    "MicrosoftExtensionsLogging": {
      "type": "object",
      "properties": {
        "LogLevel": {
          "$ref": "#/definitions/MicrosoftExtensionsLoggingLogLevel"
        },
        "Console": {
          "type": "object",
          "properties": {
            "DisableColors": {
              "type": "boolean"
            },
            "Format": {
              "enum": [ "Default", "Systemd" ]
            },
            "LogToStandardErrorThreshold": {
              "enum": [ "Trace", "Debug", "Information", "Warning", "Error", "Critical", "None" ]
            },
            "IncludeScopes": {
              "type": "boolean"
            },
            "TimestampFormat": {
              "type": "string"
            },
            "LogLevel": {
              "$ref": "#/definitions/MicrosoftExtensionsLoggingLogLevel"
            }
          }
        },
        "Debug": {
          "type": "object",
          "properties": {
            "LogLevel": {
              "$ref": "#/definitions/MicrosoftExtensionsLoggingLogLevel"
            }
          }
        },
        "EventLog": {
          "type": "object",
          "properties": {
            "LogLevel": {
              "$ref": "#/definitions/MicrosoftExtensionsLoggingLogLevel"
            }
          }
        },
        "ElmahIo": {
          "type": "object",
          "properties": {
            "LogLevel": {
              "$ref": "#/definitions/MicrosoftExtensionsLoggingLogLevel"
            }
          }
        },
        "NLog": {
          "type": "object",
          "description": "NLog Provider Options",
          "examples": [
            {
              "IncludeScopes": false,
              "ParseMessageTemplates": true,
              "CaptureMessageProperties": true
            }
          ],
          "additionalProperties": true,
          "properties": {
            "IncludeScopes": {
              "type": "boolean",
              "description": "Enable capture of scope information and inject into `NestedDiagnosticsLogicalContext` and `MappedDiagnosticsLogicalContext`",
              "default": true,
              "examples": [
                false
              ]
            },
            "ParseMessageTemplates": {
              "type": "boolean",
              "description": " Use the NLog engine for parsing the message template (again) and format using the NLog formatter",
              "default": false,
              "examples": [
                true
              ]
            },
            "CaptureMessageTemplates": {
              "type": "boolean",
              "description": "Enable structured logging by capturing message template parameters",
              "default": true,
              "examples": [
                false
              ]
            },
            "CaptureMessageProperties": {
              "type": "boolean",
              "description": "Enable capture of properties from the ILogger-State-object",
              "default": true,
              "examples": [
                false
              ]
            },
            "EventIdSeparator": {
              "type": "string",
              "description": "Separator between for EventId.Id and EventId.Name.",
              "default": "_",
              "examples": [
                "-",
                ".",
                ""
              ]
            },
            "IgnoreEmptyEventId": {
              "type": "boolean",
              "description": "Skip allocation of `LogEventInfo.Properties` dictionary",
              "default": true,
              "examples": [
                false
              ]
            },
            "ShutdownOnDispose": {
              "type": "boolean",
              "description": "Shutdown NLog on dispose",
              "default": false,
              "examples": [
                true
              ]
            }
          }
        }
      }
    },
    "AllowedHosts": {
      "type": "string"
    },
    "Kestrel": {
      "type": "object",
      "properties": {
        "Limits": {
          "type": "object",
          "properties": {
            "MaxConcurrentConnections": {
              "type": "integer"
            },
            "MaxConcurrentUpgradedConnections": {
              "type": "integer"
            }
          }
        },
        "DisableStringReuse": {
          "type": "boolean"
        },
        "EndpointDefaults": {
          "type": "object",
          "properties": {
            "Protocols": {
              "type": "string"
            }
          }
        },
        "Endpoints": {
          "type": "object",
          "properties": {
            "Http": {
              "type": "object",
              "properties": {
                "Url": {
                  "type": "string",
                  "format": "uri"
                }
              }
            },
            "HttpsInlineCertFile": {
              "type": "object",
              "properties": {
                "Url": {
                  "type": "string",
                  "format": "uri"
                },
                "Certificate": {
                  "type": "object",
                  "properties": {
                    "Path": {
                      "type": "string"
                    },
                    "Password": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "HttpsInlineCertStore": {
              "type": "object",
              "properties": {
                "Url": {
                  "type": "string",
                  "format": "uri"
                },
                "Certificate": {
                  "type": "object",
                  "properties": {
                    "Subject": {
                      "type": "string"
                    },
                    "Store": {
                      "type": "string"
                    },
                    "Location": {
                      "type": "string"
                    },
                    "AllowInvalid": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "HttpsDefaultCert": {
              "type": "object",
              "properties": {
                "Url": {
                  "type": "string",
                  "format": "uri"
                }
              }
            },
            "Https": {
              "type": "object",
              "properties": {
                "Url": {
                  "type": "string",
                  "format": "uri"
                },
                "Certificate": {
                  "type": "object",
                  "properties": {
                    "Path": {
                      "type": "string"
                    },
                    "Password": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "patternProperties": {
    "^WebOptimizer$": { "$ref": "#/definitions/webOptimizer" },
    "^webOptimizer$": { "$ref": "#/definitions/webOptimizer" },
    "^weboptimizer$": { "$ref": "#/definitions/webOptimizer" },
    "^(cdn|Cdn)$": { "$ref": "#/definitions/cdn" },
    "^(pwa|PWA|Pwa)$": { "$ref": "#/definitions/pwa" },
    "^(ElmahIo|Elmahio|elmahIo|elmahio)$": { "$ref": "#/definitions/ElmahIo" },
    "^(logging|Logging)$": { "$ref": "#/definitions/MicrosoftExtensionsLogging" },
    "^(nlog|Nlog|NLog)$": { "$ref": "#/definitions/NLog" },
    "^(allowedhosts|Allowedhosts|allowedHosts|AllowedHosts)$": { "$ref": "#/definitions/AllowedHosts" },
    "^(kestrel|Kestrel)$": { "$ref": "#/definitions/Kestrel" }
  }
}
