Codegen does not implement @clientDefaultValue decorator

Open
#898 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
devtools

Research direction

Start in the affected test crate, test/spector/azure/client-generator-core/client-default-value, and read the integration test file, including the tests disabled with #[ignore]. Trace the generated options, model defaults, and client-method behavior from those tests; done means the ignored scenarios pass without callers manually supplying the declared defaults.

Written by the indexing model from the issue text.

Description

bug CodeGen

Summary

The Rust emitter does not implement the @clientDefaultValue TypeSpec decorator. Parameters and model properties annotated with @clientDefaultValue are generated as plain Option<T> fields with no default values applied.

Expected behavior

  • Options structs: Fields with @clientDefaultValue should have their defaults pre-populated in the Default trait implementation.
  • Model structs: Fields with @clientDefaultValue (e.g. retry, tier, timeout on ModelWithDefaultValues) should be pre-populated with their default values in the Default impl.
  • Client methods: When the user does not provide a value, the generated client should automatically apply the declared default before sending the request.

Actual behavior

All @clientDefaultValue fields are generated as Option<T> defaulting to None. Callers must manually provide the default values.

Affected crate

test/spector/azure/client-generator-core/client-default-value

Test impact

Several integration tests in this crate have been disabled with #[ignore] because they were working around this limitation by manually providing default values. See the test file for details.

Dominant language
Rust
Stars
7
Forks
11
Avg merge
14h 15m
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/typespec-rust

All issues in Azure/typespec-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.