feat(schema): allow root $schema prop
this allows a config file to reference the config schema for validation via editor/IDE
MODIFY
packages/appium/lib/schema/schema.js
packages/appium/lib/schema/schema.js
@@ -43,6 +43,8 @@ export class RoachHotelMap extends Map {
*/
export const ALLOWED_SCHEMA_EXTENSIONS = new Set(['.json', '.js', '.cjs']);
+const SCHEMA_KEY = '$schema';
+
/**
* A wrapper around Ajv and schema-related functions.
*
@@ -441,6 +443,9 @@ class AppiumSchema {
for (const {properties, prefix} of stack) {
const pairs = _.toPairs(properties);
for (const [key, value] of pairs) {
+ if (key === SCHEMA_KEY) {
+ continue;
+ }
const {properties, $ref} = value;
if (properties) {
stack.push({

MODIFY
packages/schema/lib/appium-config-schema.js
packages/schema/lib/appium-config-schema.js
@@ -9,6 +9,13 @@ export const AppiumConfigJsonSchema = /** @type {const} */ ({
additionalProperties: false,
description: 'A schema for Appium configuration files',
properties: {
+ $schema: {
+ description: 'The JSON schema for this file',
+ default:
+ 'https://raw.githubusercontent.com/appium/appium/master/packages/schema/lib/appium-config.schema.json',
+ type: 'string',
+ format: 'uri',
+ },
server: {
additionalProperties: false,
description: 'Configuration when running Appium as a server',

MODIFY
packages/schema/lib/appium-config.schema.json
packages/schema/lib/appium-config.schema.json
"additionalProperties": false,
"description": "A schema for Appium configuration files",
"properties": {
+ "$schema": {
+ "description": "The JSON schema for this file",
+ "default": "https://raw.githubusercontent.com/appium/appium/master/packages/schema/lib/appium-config.schema.json",
+ "type": "string",
+ "format": "uri"
+ },
"server": {
"additionalProperties": false,
"description": "Configuration when running Appium as a server",

MODIFY
packages/types/lib/appium-config.ts
packages/types/lib/appium-config.ts
@@ -134,6 +134,10 @@ export type WebhookConfig = string;
* A schema for Appium configuration files
*/
export interface AppiumConfiguration {
+ /**
+ * The JSON schema for this file
+ */
+ $schema?: string;
server?: ServerConfig;
}
/**

feat(schema): allow root $schema prop

this allows a config file to reference the config schema for validation via editor/IDE