Skip to content

Fix inline enum query/path params to use typed enums instead of String#779

Merged
johnbatty merged 4 commits into
microsoft:mainfrom
johnbatty:fix-recursion-level-enum
Apr 19, 2026
Merged

Fix inline enum query/path params to use typed enums instead of String#779
johnbatty merged 4 commits into
microsoft:mainfrom
johnbatty:fix-recursion-level-enum

Conversation

@johnbatty

@johnbatty johnbatty commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #78.

The recursionLevel query parameter on git::items::get and git::items::list was the reported case, but the same problem affected 105 parameters across all API areas — any parameter with type: string, an enum field, and an x-ms-enum extension was being generated as impl Into<String> instead of a typed enum.

Root cause

WebParameter::type_name() in the codegen called get_type_name_for_schema(), which returned TypeName::String for all string-typed parameters and discarded the enum / x-ms-enum fields entirely.

Fix

Two changes to the code generator — no spec patches required:

  1. autorust/codegen/src/spec.rs

    • WebParameter::type_name() now checks for non-empty enum_ + x_ms_enum.name and returns TypeName::Reference(name) instead of TypeName::String.
    • New Spec::inline_parameter_enum_schemas() collects synthetic Schema entries for all inline enum parameters so the models codegen can generate a named enum type for each.
  2. autorust/codegen/src/codegen_models.rs

    • all_schemas() calls inline_parameter_enum_schemas() to include those synthetic schemas alongside definition-based schemas.
    • All generated enums now implement std::fmt::Display, so enum values serialise correctly into URL query/path parameters via .to_string().

Effect

All 105 affected parameters across build, git, release, wit, tfvc, wiki, distributedTask, etc. now use typed enums. Examples:

Module Parameter Before After
git::items recursionLevel impl Into<String> impl Into<models::VersionControlRecursionType>
build::builds statusFilter impl Into<String> impl Into<models::BuildStatus>
build::builds resultFilter impl Into<String> impl Into<models::BuildResult>
release statusFilter impl Into<String> impl Into<models::ReleaseStatus>
git::pull_requests searchCriteria.status impl Into<String> impl Into<models::PullRequestStatus>
tfvc recursionLevel impl Into<String> impl Into<models::VersionControlRecursionType>

Breaking change

Callers passing string literals for any of the 105 affected parameters will need to switch to the enum type. Example:

// Before
git_client.items_client().list(org, repo, project)
    .recursion_level("Full")

// After
use azure_devops_rust_api::git::models::VersionControlRecursionType;
git_client.items_client().list(org, repo, project)
    .recursion_level(VersionControlRecursionType::Full)

Test plan

  • ./build.sh succeeds
  • cargo clippy --all-features -- --deny warnings passes
  • cargo clippy --all-features --examples -- --deny warnings passes

🤖 Generated with Claude Code

johnbatty and others added 2 commits April 19, 2026 17:27
…Type enum

The recursionLevel query parameter on git::items::get and git::items::list
was typed as impl Into<String>. It now uses models::VersionControlRecursionType,
a proper enum with variants None, OneLevel, OneLevelPlusNestedEmptyFolders, Full.

Changes:
- Patcher: add VersionControlRecursionType definition to git.json and replace
  the inline string enum on both the paths and x-ms-paths items operations
- Codegen: generate Display impl for all enum types so they can be serialised
  as URL query parameter values
- Examples: update git_items_list and git_repo_download_zip to use the new type

Closes microsoft#78

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously, the patcher was adding spec patches for each inline enum
query parameter (e.g. recursionLevel). This replaces that approach with
a proper code generator fix.

Changes:
- spec.rs: WebParameter::type_name() now returns TypeName::Reference(name)
  for parameters with a non-empty `enum` field and an `x-ms-enum.name`,
  instead of TypeName::String.
- spec.rs: new Spec::inline_parameter_enum_schemas() collects synthetic
  Schema entries for all inline enum parameters across all operations so
  the models codegen can generate named enum types for them.
- codegen_models.rs: all_schemas() calls inline_parameter_enum_schemas()
  to include those synthetic schemas alongside definition-based schemas.
- patcher.rs: remove the now-unnecessary patch_git_items_recursion_level
  patch function.

This automatically fixes all 105 inline enum query/path parameters across
all API areas (build, git, release, wit, tfvc, wiki, etc.), generating
proper typed enum types instead of impl Into<String> for each.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@johnbatty johnbatty changed the title Fix git items recursionLevel parameter to use VersionControlRecursion… Fix inline enum query/path params to use typed enums instead of String Apr 19, 2026
johnbatty and others added 2 commits April 19, 2026 19:41
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@johnbatty johnbatty merged commit eeb1df3 into microsoft:main Apr 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git::items::list recursion_level should be an enum rather than a String

1 participant