Skip to content

Add schema selection for core, JSON, and failsafe YAML schemas #61

Description

Context

YAML 1.2.2 recommends failsafe, JSON, and core schemas. Schema choice controls how plain scalars resolve to tags and therefore which native values users receive.

Official YAML 1.2.2 references:

Current State

The module exposes the YAML 1.2 core schema as the default behavior. There is no public schema-selection parameter for failsafe or JSON schema behavior.

Objective

Let callers choose core, JSON, or failsafe schema behavior for plain scalar resolution while preserving the current core schema default.

PowerShell Design Considerations

  • Use a discoverable -Schema parameter with validated values rather than separate cmdlets.
  • Keep parameter symmetry between conversion and file import, and apply schema-aware validation to test/format/merge surfaces.
  • Preserve rich object behavior by resolving scalars before projection, not after PowerShell object construction.
  • Consider parameter-set interactions with future typed projection and resolver parameters so schema selection remains composable.

Tasks

  • Add schema selection for core, JSON, and failsafe scalar resolution.
  • Keep core schema as the default observable behavior.
  • Make JSON schema reject unresolved plain scalars with a classified error.
  • Make failsafe schema resolve all plain scalars as strings.
  • Apply selected schema to key equality and stream validation surfaces.
  • Document schema behavior with examples relevant to PowerShell types.

Benefits

  • Lets strict JSON-compatible YAML users reject non-JSON scalar forms.
  • Lets configuration authors preserve version-like and identifier-like values as strings.
  • Keeps default behavior stable for existing users.

Acceptance Criteria

  • -Schema Core matches current default behavior.
  • -Schema Failsafe returns plain scalar values as strings.
  • -Schema JSON accepts JSON scalar forms and rejects core-only forms.
  • Test-Yaml, Format-Yaml, and Merge-Yaml honor schema selection where scalar resolution matters.
  • Parameter behavior is symmetric on file import and string conversion surfaces.

Related

  • Spec folder: spec/Schema-Selection.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions