Repository navigation
Declare the output contract for Json's public commands #43
Description
Context and request
None of the three public commands declares [OutputType()], and none documents .INPUTS, .OUTPUTS, or .NOTES. The MSX PowerShell function standard treats [OutputType()] and its matching .OUTPUTS block as the contract between a function and its callers, and PlatyPS renders both into the generated reference pages published at psmodule.io/Json. Today those pages carry no output contract at all.
Each command already has .SYNOPSIS, .DESCRIPTION, at least one .EXAMPLE, and a correct .LINK, so this completes existing help rather than writing it from scratch.
Acceptance criteria.
Format-Json,Import-Json, andExport-Jsoneach declare[OutputType()], scoped per parameter set where the sets return different types.- Each documents
.INPUTSand.OUTPUTS, with a description for every entry and fully-qualified .NET type names. .OUTPUTSmatches[OutputType()]exactly.- Where no parameter accepts pipeline input,
.INPUTSreadsNonewithYou can't pipe objects to <CommandName>.as its description. Get-Help <Command> -Fullshows inputs and outputs for all three commands.- The generated reference pages render the type as a heading with the description as body text below it.
Technical decisions
.INPUTS and .OUTPUTS use the PlatyPS blank-line format — type name on the first line, blank line, then the description as a plain paragraph:
.OUTPUTS
System.String
The formatted JSON text.The single-line System.String. Description. form shown in about_Comment_Based_Help is not used: it triggers MD026 and puts a full sentence inside a ### heading when PlatyPS v2 processes it.
Type names are fully qualified — System.String, System.Management.Automation.PSCustomObject, System.IO.FileInfo — not accelerators.
Export-Json needs care on [OutputType()]. It emits System.IO.FileInfo only when -PassThru is supplied and nothing otherwise. Since that is a switch rather than a parameter set, a single unscoped [OutputType([System.IO.FileInfo])] is correct, with .OUTPUTS stating that output is produced only with -PassThru.
Import-Json currently emits objects carrying an injected _SourceFile property. The .OUTPUTS description documents the corrected contract — the deserialized document — not the current polluted one, so this should land after or alongside that correction.
This is a documentation and attribute change with no runtime behaviour change, which is why it is separated from the structural work on the same functions. src/ matches ImportantFilePatterns, so it still triggers a full build and warrants a Patch label.
Implementation plan
- Add
[OutputType([System.String])]toFormat-Jsonwith.INPUTScovering both pipeline-bound parameter sets and.OUTPUTSdescribing the formatted JSON text - Add
[OutputType([System.Management.Automation.PSCustomObject])]toImport-Jsonwith.INPUTSfor the pipeline-boundPathand.OUTPUTSdescribing the deserialized document - Add
[OutputType([System.IO.FileInfo])]toExport-Jsonwith.INPUTScovering both pipeline-bound sets and.OUTPUTSnoting output only occurs with-PassThru - Add
.NOTESwhere there is genuinely something a caller needs to know, and omit it where there is not - Verify
Get-Help <Command> -Fullrenders all sections correctly for each command - Confirm the generated documentation pages render the heading and body separation as intended
- Confirm
.OUTPUTSand[OutputType()]agree for every command
Activity