Back to .md Directory

Tasklist

- [x] Read the `README.md` to understand what the project is.

May 2, 2026
0 downloads
0 views
ai
View source

Tasklist

  • Read the README.md to understand what the project is.
  • Confirm the git repository is initialized and clean.
  • Create .ai/redocly-cli.md describing the use of the CLI tool available at: https://github.com/redocly/redocly-cli
  • Create .ai/openapi-3.0.md describing the OpenAPI 3.0 Schema standard.
  • Create .ai/multi-file-definitions.md describing the use of multi-file-definitions.
  • Clone https://github.com/paul-fornage/wled-json-api-library.git as a submodule and commit the change.
  • Review the AI documentation in .ai/docs/*.md and the README.md, then generate a plan of iterative tasks in this document tasks.md to create a Redocly multi-file OpenAPI 3 Schema based on the Rust code in wled-json-api-library according to the AI documentation and the README.md
  • Verify compatibility with WLED 14.0+ as noted in library README
  • Please read the @openapi-3.0.md and @multi-file-definitions.md and @README.md Then verify the entire OpenAPI schema in ./openapi compared to the Rust code in ./wled-json-api-library/src/ Confirm all paths, structures, and field types match the Rust code.

OpenAPI Schema Creation Plan

Initial Setup Phase

  • Initialize the OpenAPI project structure following the multi-file format
  • Create the root openapi.yaml file with basic API information
  • Set up the folder structure for components, paths, and code samples
  • Configure .redocly.yaml for linting and documentation settings

Major API Feature Endpoints (from wled-json-api-library analysis)

Based on the Rust library analysis, the WLED JSON API has these major feature endpoints:

  1. State Management (/json/state)

    • GET: Retrieve current device state (brightness, on/off, effects, segments, etc.)
    • POST: Update device state
  2. Configuration Management (/json/cfg)

    • GET: Retrieve device configuration
    • POST: Update device configuration (network, hardware, defaults, etc.)
  3. Device Information (/json/info)

    • GET: Retrieve device info (version, hardware details, capabilities)
  4. Effects Management (/json/eff)

    • GET: Retrieve available effects list
  5. Color Palettes (/json/pal)

    • GET: Retrieve available color palettes
  6. Network Discovery (/json/nodes)

    • GET: Retrieve discovered WLED nodes on network
  7. Network Information (/json/net)

    • GET: Retrieve network configuration and status
  8. Live Data (/json/live)

    • GET: Retrieve live/realtime data stream information

Iterative Development Process

Documentation to Review for Each Iteration

For each major API feature group, review these documents before starting:

  • .ai/docs/openapi-3.0.md - OpenAPI schema standards and requirements
  • .ai/docs/multi-file-definitions.md - File organization and $ref usage
  • .ai/docs/redocly-cli.md - CLI commands for validation and building
  • wled-json-api-library/README.md - API usage examples and compatibility notes
  • Relevant Rust structure files in wled-json-api-library/src/structures/

Iteration 1: State Management (/json/state)

  1. Analysis Phase

    • Review wled-json-api-library/src/structures/state.rs for data structures
    • Review wled-json-api-library/src/wled.rs methods: get_state_from_wled(), flush_state()
    • Identify:
      • State properties (on/off, brightness, effects, segments, etc.)
      • Request/response data structures for GET and POST operations
      • Error responses and status codes
      • Query parameters and optional fields
  2. Schema Creation Phase

    • Create components/schemas/State.yaml - main state object schema
    • Create components/schemas/Segment.yaml - segment configuration schema
    • Create components/schemas/StateResponse.yaml - GET response wrapper
    • Create components/schemas/StateRequest.yaml - POST request schema
    • Create paths/json_state.yaml - GET and POST operations
    • Define common error responses in components/responses/
  3. Documentation Phase

    • Add detailed descriptions for all state properties
    • Include examples from the Rust library usage
    • Add code samples for state operations
    • Document valid ranges and constraints
  4. Validation Phase

    • Run npm test to validate schema
    • Run npm start to preview documentation
    • Fix any validation errors

Iteration 2: Configuration Management (/json/cfg)

  1. Analysis Phase

    • Review wled-json-api-library/src/structures/cfg/ directory structure
    • Review configuration sub-modules (def, hw, network, etc.)
    • Review wled-json-api-library/src/wled.rs methods: get_cfg_from_wled(), flush_config()
    • Identify:
      • Hardware configuration options
      • Network settings (WiFi, Ethernet, AP mode)
      • Default behavior settings
      • Interface and remote control settings
  2. Schema Creation Phase - Core Structure

    • Create components/schemas/Config.yaml - main configuration object (placeholder)
    • Create paths/json_cfg.yaml - GET and POST operations
    • Update common error responses
    • Create components/schemas/ConfigResponse.yaml and ConfigRequest.yaml
  3. Schema Creation Phase - Detailed Component Schemas

    • Implement detailed components/schemas/config/Config.yaml based on Rust Cfg struct
    • Implement components/schemas/config/AccessPointConfig.yaml from cfg_ap.rs
    • Implement components/schemas/config/DefaultConfig.yaml from cfg_def.rs
    • Implement components/schemas/config/DmxConfig.yaml from cfg_dmx.rs
    • Implement components/schemas/config/EthernetConfig.yaml from cfg_eth.rs
    • Implement components/schemas/config/HardwareConfig.yaml from cfg_hw/mod.rs
    • Implement components/schemas/config/LedConfig.yaml from cfg_hw/cfg_hw_led.rs (Note: LED config is implemented as part of HardwareConfig.yaml since it's not a standalone schema in the Rust code)
    • Implement components/schemas/config/DeviceIdentification.yaml from cfg_id.rs
    • Implement components/schemas/config/InterfaceConfig.yaml from cfg_if2.rs
    • Implement components/schemas/config/LightConfig.yaml from cfg_light.rs
    • Implement components/schemas/config/NetworkConfig.yaml from cfg_nw.rs
    • Implement components/schemas/config/AnalogClock.yaml from cfg_ol.rs
    • Implement components/schemas/config/OtaConfig.yaml from cfg_ota.rs
    • Implement components/schemas/config/RemoteConfig.yaml from cfg_remote.rs
    • Implement components/schemas/config/TimersConfig.yaml from cfg_timers.rs
    • Implement components/schemas/config/WifiConfig.yaml from cfg_wifi.rs
  4. Documentation Phase

    • Document configuration categories and their purposes
    • Add examples for common configuration scenarios
    • Include warnings about dangerous configuration changes
    • Document backup/restore considerations
  5. Validation Phase

    • Run validation and preview tools with detailed schemas
    • Test configuration examples with all components
    • Fix any issues with detailed implementations

Iteration 3: Device Information (/json/info)

  1. Analysis Phase

    • Review wled-json-api-library/src/structures/info.rs
    • Review get_info_from_wled() method
    • Identify:
      • Version information (firmware, build)
      • Hardware capabilities and limitations
      • Runtime statistics and status
      • Feature availability flags
  2. Schema Creation Phase

    • Create components/schemas/DeviceInfo.yaml
    • Create components/schemas/VersionInfo.yaml
    • Create components/schemas/HardwareInfo.yaml
    • Create paths/json_info.yaml - GET operation only
    • Define read-only property specifications
  3. Documentation Phase

    • Document version compatibility information
    • Add examples of different hardware configurations
    • Document capability flags and their meanings
    • Document WLED version differences
  4. Validation Phase

    • Run validation and preview tools with detailed schemas
    • Test configuration examples with all components
    • Fix any issues with detailed implementations

Iteration 4: Effects and Palettes (/json/eff, /json/pal)

  1. Analysis Phase

    • Review wled-json-api-library/src/structures/effects.rs
    • Review wled-json-api-library/src/structures/palettes.rs
    • Review corresponding getter methods
    • Identify:
      • Effect list structure and metadata
      • Palette list structure and color data
      • Effect parameters and capabilities
  2. Schema Creation Phase

    • Create components/schemas/Effects.yaml
    • Create components/schemas/Effect.yaml
    • Create components/schemas/Palettes.yaml
    • Create components/schemas/Palette.yaml
    • Create paths/json_eff.yaml and paths/json_pal.yaml
  3. Documentation Phase

    • Document effect categories and behaviors
    • Add palette color format specifications
    • Include visual examples where applicable
  4. Validation Phase

    • Validate effect and palette data structures

Iteration 5: Network Features (/json/nodes, /json/net)

  1. Analysis Phase

    • Review wled-json-api-library/src/structures/nodes.rs
    • Review wled-json-api-library/src/structures/net.rs
    • Review corresponding getter methods
    • Identify:
      • Node discovery protocol and data
      • Network status and configuration
      • Multi-device coordination features
  2. Schema Creation Phase

    • Create network-related schemas
    • Create node discovery schemas
    • Create corresponding path definitions
  3. Documentation Phase

    • Document network discovery mechanisms
    • Explain multi-device synchronization
    • Add network troubleshooting information
  4. Validation Phase

    • Test with multiple WLED devices
    • Validate network configuration scenarios
    • Run validation and preview tools with detailed schemas
    • Test configuration examples with all components
    • Fix any issues with detailed implementations

Iteration 6: Live Data and Streaming (/json/live)

  1. Analysis Phase

    • Review wled-json-api-library/src/structures/live.rs
    • Review streaming capabilities and limitations
    • Note: The library README mentions JSON streaming "sucks and is slow"
    • Identify real-time data structures
  2. Schema Creation Phase

    • Create live data schemas
    • Document streaming limitations
    • Create appropriate path definitions
  3. Documentation Phase

    • Document streaming alternatives (DDP protocol)
    • Add performance considerations
    • Include usage recommendations
  4. Validation Phase

    • Run validation and preview tools with detailed schemas
    • Test configuration examples with all components
    • Fix any issues with detailed implementations

Finalization Phase

  • Bundle the complete multi-file definition
  • Generate comprehensive API documentation
  • Create final validation report
  • Update project README with schema information
  • Create usage examples and code samples

Schema-Implementation Alignment Tasks

Based on the analysis in docs/implementation-vs-schema-gaps.md, the following tasks are needed to bring the OpenAPI schema to full parity with the actual WLED JSON API implementation:

Phase 1: Missing API Endpoints

Task 1.1: Add Combined State + Info Endpoint

  • Create paths/json_si.yaml for /json/si endpoint
  • Define GET operation returning combined state and info objects
  • Create response schema components/schemas/StateInfoResponse.yaml
  • Add path reference to main openapi.yaml
  • Add code samples and documentation

Task 1.2: Add Effect Data Endpoint

  • Create paths/json_fxda.yaml for /json/fxda endpoint
  • Define GET operation returning array of effect metadata
  • Create response schema components/schemas/EffectDataResponse.yaml
  • Document effect metadata format (data after '@' character)
  • Add path reference to main openapi.yaml

Task 1.3: Add Paginated Palette Endpoint

  • Create paths/json_palx.yaml for /json/palx endpoint
  • Define GET operation with optional page query parameter
  • Create response schema components/schemas/PaginatedPalettesResponse.yaml
  • Document pagination structure with m (max pages) and p (palette data)
  • Include color data arrays vs simple names
  • Add path reference to main openapi.yaml

Task 1.4: Add Base JSON Endpoint

  • Create paths/json.yaml for /json endpoint (no suffix)
  • Define GET operation returning complete API data
  • Create response schema components/schemas/CompleteApiResponse.yaml
  • Include state, info, effects, and palette names
  • Add path reference to main openapi.yaml

Phase 2: State Object Field Completion

Task 2.1: Add Missing Core State Fields

  • Add ledmap field to components/schemas/State.yaml
    • Type: integer
    • Description: "Current LED map ID"
    • ReadOnly: true
  • Add error field to components/schemas/State.yaml
    • Type: integer
    • Description: "Error code if present"
    • ReadOnly: true

Task 2.2: Complete Nightlight Object

  • Add rem field to components/schemas/Nightlight.yaml
    • Type: integer
    • Description: "Remaining time in seconds (-1 if inactive)"
    • ReadOnly: true

Task 2.3: Complete UDP Sync Object

  • Add sgrp field to components/schemas/UdpSync.yaml
    • Type: integer
    • Description: "Sync groups (bitfield)"
  • Add rgrp field to components/schemas/UdpSync.yaml
    • Type: integer
    • Description: "Receive groups (bitfield)"

Task 2.4: Complete Segment Object

  • Add lc field to components/schemas/Segment.yaml
    • Type: integer
    • Description: "Light capabilities bitfield"
    • ReadOnly: true
  • Add len field to components/schemas/Segment.yaml
    • Type: integer
    • Description: "Segment length (calculated from stop-start)"
    • ReadOnly: true

Phase 3: Configuration Schema Field Validation (35 Files)

Task 3.1: Setup Systematic Validation Process

  • Create validation suite framework structure (validation/ directory)
  • Set up test WLED device for comprehensive API data capture (ESP32 with Ethernet at 10.0.0.100)
  • Create data collection script (validation/scripts/collect-data.js)
    • Capture all 13 JSON API endpoints successfully
    • Implement retry logic and error handling
    • Real-world data collection from WLED v0.15.0 ESP32_Ethernet device
  • Create comprehensive data sanitization framework (validation/scripts/sanitize-data.js)
    • Pattern-based sensitive data detection and replacement
    • All sensitive data properly sanitized (SSIDs, MAC addresses, IPs, passwords, device names)
    • Context-aware sanitization for nested structures and arrays
  • Integrate npm script automation (validate:collect, validate:sanitize)
  • Create validation documentation (validation/README.md)
  • Setup git security (.gitignore excludes sensitive captured-data/, commits safe sanitized-data/)
  • Create validation script/tool to systematically compare captured JSON vs OpenAPI schemas
  • Create configuration validation matrix spreadsheet covering all endpoints
  • Build schema validation comparison tooling
  • Generate automated validation reports identifying:
    • Missing fields in schemas
    • Incorrect field types or constraints
    • Extra fields in schemas not in implementation
    • Field name mismatches
    • Platform-specific conditional fields
  • Document complete validation methodology and criteria

Task 3.2: Core Configuration Structure Validation

Use captured validation/sanitized-data/esp32-ethernet/config.json for validation

  • Config.yaml - Main configuration wrapper structure
  • ConfigRequest.yaml - POST request structure
  • ConfigResponse.yaml - GET response structure

Task 3.3: Network Configuration Validation (High Priority)

  • NetworkConfig.yaml - Main network configuration
  • NetworkInstance.yaml - Individual WiFi network instances
  • WifiConfig.yaml - WiFi-specific settings
  • AccessPointConfig.yaml - AP mode configuration
  • EthernetConfig.yaml - KNOWN ISSUE: Change relaytype, verify enums

Task 3.4: Hardware Configuration Validation (High Priority)

  • HardwareConfig.yaml
    • LED configuration
    • Communication settings
    • Button configuration
    • Infrared settings
    • Relay configuration
    • Interface configuration
  • LedConfig.yaml
    • Total LED count
    • Power limit
    • LED matrix
    • Individual LED control
    • LED segments
  • RelayConfig.yaml
    • Pin configuration
    • Reverse logic
    • Open drain output

Task 3.5: Interface Configuration Validation (Medium Priority)

  • InterfaceConfig.yaml - Main interface wrapper
  • SyncConfig.yaml - UDP sync configuration
    • Check sync port configurations
    • Verify group settings
  • MqttConfig.yaml - MQTT broker configuration
    • Verify MQTT settings structure
    • Check topic configurations
  • HueConfig.yaml - Philips Hue integration
  • NtpConfig.yaml - NTP time synchronization
    • Validate NTP configuration fields
  • LiveConfig.yaml - Real-time data streaming
  • DmxConfig.yaml - DMX protocol configuration
  • NodesConfig.yaml - Node discovery settings
  • VoiceAssistantConfig.yaml - Alexa integration

Task 3.6: Behavior Configuration Validation (Medium Priority)

  • LightConfig.yaml - Light behavior settings
    • Verify gamma correction structure
    • Check transition settings
  • GammaCorrection.yaml - Gamma correction specifics
  • TransitionConfig.yaml - Transition timing
    • Fixed pal field type to boolean
    • Removed unused mode field
    • Clarified duration units (centiseconds)
  • NightlightConfig.yaml - Nightlight behavior
    • Added detailed mode descriptions
    • Clarified duration behavior for each mode
    • Added note about macro execution timing
    • Added sunrise/sunset mode specifics
  • DefaultConfig.yaml - Boot-up defaults
    • Clarified preset number range (0 = no preset, 1-250 = preset number)
    • Added note about LED state when turnOnAtBoot is false
    • Added detail about default brightness behavior
    • Updated example to show default state
  • AnalogClock.yaml - Clock display settings
    • Added missing osb field for solid black mode
    • Improved field descriptions for clarity
    • Clarified min/max LED boundaries
    • Added note about 12 o'clock position
  • TimersConfig.yaml - COMPLEX: Scheduling and automation
    • Verify timer instance structures
    • Check countdown configuration
    • Validate scheduling fields
    • Fixed goal field to be array type

Task 3.7: Device Configuration Validation (Low Priority)

  • DeviceIdentification.yaml - Device naming and mDNS
  • OtaConfig.yaml - Over-the-air update settings
  • RemoteConfig.yaml - Remote control settings
  • ColorOrderMap.yaml - LED color order mapping
  • Security Configuration Validation
    • Verify security configuration structure
    • Check PIN configuration
    • Validate OTA settings
    • Add missing SecurityConfig.yaml schema
    • Add SecurityConfig reference to Config.yaml

Task 3.8: Extended Configuration Validation Testing

Primary validation can begin immediately with existing sanitized data

  • Capture actual /json/cfg responses from ESP32 with Ethernet ✅ (validation/sanitized-data/esp32-ethernet/)
  • Capture additional device configurations:
    • ESP8266 basic configuration
    • ESP32 with 2D matrix
    • Different usermod configurations
  • Run schema validation against captured responses
  • Document validation failures and required fixes
  • Create automated validation test suite

Phase 4: Device Information Completion

Task 4.1: Add Missing Platform-Specific Fields

  • Add cn field to components/schemas/DeviceInfoResponse.yaml
    • Type: string
    • Description: "Codename"
    • ReadOnly: true
  • Add release field to components/schemas/DeviceInfoResponse.yaml
    • Type: string
    • Description: "Release information"
    • ReadOnly: true
  • Add clock field to components/schemas/DeviceInfoResponse.yaml
    • Type: integer
    • Description: "CPU frequency in MHz"
    • ReadOnly: true
  • Add flash field to components/schemas/DeviceInfoResponse.yaml
    • Type: integer
    • Description: "Flash memory size in MB"
    • ReadOnly: true
  • Add ndc field to components/schemas/DeviceInfoResponse.yaml
    • Type: integer
    • Description: "Node discovery count (-1 if disabled)"
    • ReadOnly: true

Task 4.2: Platform-Specific Conditional Fields

  • Document ESP32 vs ESP8266 specific fields
  • Add conditional schema support for different builds
  • Include feature availability flags documentation

Task 5.2: Documentation Finalization

  • Update README.md with schema completion status
  • Document known limitations and issues
  • Create troubleshooting guide

Related Documents