CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-autorest--configuration

Configuration management system for AutoRest's REST API client library generator

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

configuration-schema.mddocs/

Configuration Schema

Schema validation system providing predefined schemas for AutoRest configuration and extensible validation rules.

Core Schema Components

autorestConfigurationProcessor

const autorestConfigurationProcessor: ConfigurationSchemaProcessor;

interface ConfigurationSchemaProcessor {
  processConfiguration(config: any, options: any): ProcessingResult;
}

interface ProcessingResult {
  value?: AutorestNormalizedConfiguration;
  errors?: ValidationError[];
}

Main configuration processor that validates configuration objects against the AutoRest schema.

Usage:

import { autorestConfigurationProcessor } from "@autorest/configuration";

const result = autorestConfigurationProcessor.processConfiguration(rawConfig, {
  logger: logger
});

if ("errors" in result) {
  // Handle validation errors
  for (const error of result.errors) {
    console.error(`${error.path.join(".")}: ${error.message}`);
  }
} else {
  // Use validated configuration
  const validConfig = result.value;
}

AUTOREST_INITIAL_CONFIG

const AUTOREST_INITIAL_CONFIG: AutorestNormalizedConfiguration;

Initial default configuration values used as the base for all configurations.

Default Values:

  • Core settings with sensible defaults
  • Extension configurations set to false
  • Validation and processing flags

Configuration Categories

AUTOREST_CONFIGURATION_CATEGORIES

const AUTOREST_CONFIGURATION_CATEGORIES: {
  readonly logging: CategoryDefinition;
  readonly installation: CategoryDefinition;
  readonly core: CategoryDefinition;
  readonly feature: CategoryDefinition;
  readonly extensions: CategoryDefinition;
};

interface CategoryDefinition {
  name: string;
  description?: string;
}

Configuration categories for organizing and documenting configuration options.

Categories:

  • logging - Logging configuration options
  • installation - Installation and package management
  • core - Core AutoRest settings
  • feature - Feature flags and experimental options
  • extensions - Generator and extension configurations

Supported Extensions Schema

SUPPORTED_EXTENSIONS_SCHEMA

const SUPPORTED_EXTENSIONS_SCHEMA: {
  readonly csharp: ExtensionSchemaDefinition;
  readonly go: ExtensionSchemaDefinition;
  readonly java: ExtensionSchemaDefinition;
  readonly python: ExtensionSchemaDefinition;
  readonly az: ExtensionSchemaDefinition;
  readonly typescript: ExtensionSchemaDefinition;
  readonly powershell: ExtensionSchemaDefinition;
  // ... more extensions
};

interface ExtensionSchemaDefinition {
  type: "boolean";
  category: "extensions";
  description: string;
}

Schema definitions for officially supported AutoRest extensions.

Supported Extensions:

  • csharp - Generate C# client code
  • go - Generate Go client code
  • java - Generate Java client code
  • python - Generate Python client code
  • az - Generate Azure CLI code
  • typescript - Generate TypeScript client code
  • powershell - Generate PowerShell cmdlets

Schema Type System

Configuration Property Types

type ConfigurationPropertyType = 
  | "string" 
  | "number" 
  | "boolean" 
  | "array" 
  | "dictionary" 
  | "object";

interface ConfigurationPropertyBase {
  readonly type: ConfigurationPropertyType;
  readonly description?: string;
  readonly deprecated?: boolean;
}

interface StringConfigurationProperty extends ConfigurationPropertyBase {
  type: "string";
  readonly enum?: readonly string[];
}

interface NumberConfigurationProperty extends ConfigurationPropertyBase {
  type: "number";
  readonly minimum?: number;
  readonly maximum?: number;
}

interface BooleanConfigurationProperty extends ConfigurationPropertyBase {
  type: "boolean";
}

interface ArrayConfigurationProperty extends ConfigurationPropertyBase {
  type: "array";
  readonly items: ConfigurationProperty;
}

interface DictionaryConfigurationProperty extends ConfigurationPropertyBase {
  type: "dictionary";
  readonly additionalProperties: ConfigurationProperty;
}

interface ObjectConfigurationProperty extends ConfigurationPropertyBase {
  type: "object";
  readonly properties: ConfigurationSchema;
}

type ConfigurationProperty = 
  | StringConfigurationProperty
  | NumberConfigurationProperty  
  | BooleanConfigurationProperty
  | ArrayConfigurationProperty
  | DictionaryConfigurationProperty
  | ObjectConfigurationProperty;

Complete type system for defining configuration property schemas with validation rules.

Schema Definitions

type ConfigurationSchemaDefinition<C extends string, S extends RootConfigurationSchema<C>> = {
  readonly categories: {
    [key in C]: CategoryDefinition;
  };
  readonly schema: S;
};

type RootConfigurationSchema<C extends string> = {
  readonly [key: string]: RootConfigurationProperty<C>;
};

type ConfigurationSchema = {
  readonly [key: string]: ConfigurationProperty;
};

type RootConfigurationProperty<C extends string> = ConfigurationProperty & {
  readonly category?: C;
};

Schema definition types for creating comprehensive configuration schemas with categorization.

Schema Processing

ConfigurationSchemaProcessor

class ConfigurationSchemaProcessor {
  processConfiguration(
    config: any, 
    options: ProcessingOptions
  ): ProcessingResult;
}

interface ProcessingOptions {
  logger?: AutorestLogger;
  // Additional processing options
}

interface ProcessingResult {
  value?: AutorestNormalizedConfiguration;
  errors?: ValidationError[];
}

interface ValidationError {
  code: string;
  message: string;
  path: string[];
}

Processes and validates configuration objects against defined schemas with detailed error reporting.

Usage Examples

Schema Validation

import { 
  autorestConfigurationProcessor,
  AUTOREST_INITIAL_CONFIG 
} from "@autorest/configuration";

// Validate configuration
const config = {
  "input-file": ["swagger.json"],
  "output-folder": "./generated",
  csharp: true,
  "invalid-option": "value" // This will cause validation error
};

const result = autorestConfigurationProcessor.processConfiguration(config, {
  logger: logger
});

if ("errors" in result) {
  result.errors.forEach(error => {
    console.error(`Validation error at ${error.path.join(".")}: ${error.message}`);
  });
}

Extension Schema Usage

import { SUPPORTED_EXTENSIONS_SCHEMA } from "@autorest/configuration";

// Check if extension is supported
const isCSharpSupported = "csharp" in SUPPORTED_EXTENSIONS_SCHEMA;
const extensionInfo = SUPPORTED_EXTENSIONS_SCHEMA.csharp;
console.log(extensionInfo.description); // "Generate C# client code"

Custom Schema Extension

The schema system is designed to be extensible for custom AutoRest extensions and configurations while maintaining backward compatibility with existing configurations.

docs

cli-arguments.md

configuration-loading.md

configuration-management.md

configuration-schema.md

configuration-types.md

directive-processing.md

file-resolution.md

index.md

utilities.md

tile.json