Repository navigation
[docs] Document optional parameters and programmatic value setting - #1871
James Newton-King (JamesNK) merged 7 commits into
Conversation
Documents WithOptional/WithRequired and TryGetCurrentValue/SetValueAsync on ParameterResource, added in microsoft/aspire#18108. Co-authored-by: Copilot <[email protected]>
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
docs-pr-reviewer report — [partial — phase A: key claims evaluated; phase B: not run (docs site was not served in this automated run)]Recommendation: approve Source used: Phase A — claims
Phase B — doc-testerNot run; rendering of the changed pages is not browser-checked. 🤖 Posted by aspire.dev - squad (AI Agent) |
There was a problem hiding this comment.
🟡 Changes recommended
The documentation uses unavailable API methods, has stale TypeScript declarations and an incorrect publish command, and omits important value-handling behavior.
6 open issues
Use the available AsOptional/asOptional API names · New Refresh two-slash declarations for the new APIs · New Replace nonexistent WithRequired(bool) with AsRequired() · New Use the manifest pipeline step in the publish example · New Note that empty strings count as absent values · New Clarify that publish initialization persists resolved values · New
What changed in this PR
Updates the existing parameters guide for Aspire 17.0 to document optional parameters and programmatic value management introduced by microsoft/aspire#18108.
Changes:
- Adds optional-parameter guidance with C# and TypeScript examples.
- Shows how to inspect, set, and clear parameter values programmatically.
- Adds notes on manifest publishing restrictions and value persistence.
| File | Description |
|---|---|
src/frontend/src/content/docs/fundamentals/external-parameters.mdx |
Adds two sections covering optional parameters and programmatic value management. |
Review effort: Balanced
microsoft/aspire#22217 replaced WithOptional/WithRequired(bool) with AsOptional/AsRequired. Update samples and prose, use aspire do publish-manifest, and add the new ParameterResource members to the twoslash type shims so TypeScript samples type-check. Co-authored-by: Copilot <[email protected]>
2b627d8 to
1e32bc5
Compare
Clarified behavior of SetValueAsync and its impact on deployment state. Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot <[email protected]>

Documents changes from microsoft/aspire#18108 and the follow-up API rename in microsoft/aspire#22217
@davidfowlTarget branch
Targeting
release/17.0based on the source PR milestone17.0.Why this PR is needed
microsoft/aspire#18108 adds a first-class optional-parameter model and programmatic parameter value management to
ParameterResource:AsOptional()/AsRequired()extension methods (renamed fromWithOptional()/WithRequired(bool)in [release/17.0] Address API review feedback from #22185 aspire#22217) let a parameter resolve tonullinstead of prompting or blocking publish when unset.TryGetCurrentValue(out value)/TryGetCurrentValue()let AppHost code inspect the current value without waiting on an unresolved prompt.SetValueAsync(value, cancellationToken)lets AppHost code set or clear a parameter's value programmatically, synchronizing dashboard state.DistributedApplicationExceptioninstead of emitting schema-invalid output.asOptional,asRequired,setValueAsync, andtryGetCurrentValuemembers.This is undocumented user-facing API surface (PR body "User-facing usage" section,
pr_body_has_user_facing_sectionsignal) spanning both the C# and TypeScript AppHost SDKs (polyglot_code_generator_changedsignal), so the existing parameters documentation needed updating.What changed
Added two new sections to
src/frontend/src/content/docs/fundamentals/external-parameters.mdx, placed after "Secret values" and before "Add parameters from configuration":AsOptional()/AsRequired(), the resultingnullresolution behavior for dependent resources, and the manifest-publish restriction (drawn from reviewer discussion on the source PR about the manifest schema not supporting optional parameter inputs).TryGetCurrentValueandSetValueAsync, including thatSetValueAsyncdoesn't by itself persist to user secrets or deployment state (drawn from reviewer discussion clarifying that onlyParameterProcessor.SetValueAsyncwithsaveToUserSecrets: truepersists).Both sections include matching C# and TypeScript code samples, following the page's existing
<Tabs syncKey="aspire-lang">convention.Files modified
src/frontend/src/content/docs/fundamentals/external-parameters.mdx(updated)src/frontend/scripts/generate-twoslash-types.tsandsrc/frontend/src/data/twoslash/aspire.d.ts— addsasOptional,asRequired,tryGetCurrentValue, andsetValueAsyncto the post-snapshotParameterResourceshim so the TypeScript samples type-check until the ts-modules snapshot is refreshedNo new pages were created; this is an update to the existing parameters guide.