Skip to content

[Rust][Services] Update services codegen to use WoT#1229

Draft
vaavva wants to merge 7 commits intomainfrom
vaavva/rust-wot-service-updates
Draft

[Rust][Services] Update services codegen to use WoT#1229
vaavva wants to merge 7 commits intomainfrom
vaavva/rust-wot-service-updates

Conversation

@vaavva
Copy link
Member

@vaavva vaavva commented Feb 18, 2026

This PR:

  • updates the rust services codegen script to use the new codegen and WoT files
  • regenerates the codegen files for the services
  • adjusts the service client code (only needed for Schema Registry) to handle codegen output changes related to enums.
    • A few decisions were made here:
    • to avoid churn as much as possible, the service client will return an AIOProtocolError::PayloadInvalid to match the error that would have previously been returned if the payload didn't conform to one of the correct enum values during deserialization. This maintains the same error checking as before.
    • The one change is that the nested error returned is not the same since it no longer originates from serde_json. However, the information provided in the error message conveys similar information even though it is on a different field and not an exact match.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Rust services code generation to use the new WoT (Web of Things) Thing Model-based codegen (v1.0.0.0) instead of the DTDL-based codegen (v0.10.0.0). The changes regenerate all service client code and adapt the Schema Registry client to handle enum-to-const conversions and field renames introduced by the new code generator.

Changes:

  • Updates code generation script to use codegen2 with WoT Thing Models
  • Regenerates Schema Registry, ADR Base Service, and Device Discovery Service client code
  • Converts enums to constants/strings (Format, SchemaRegistryErrorCode, SchemaRegistryErrorTarget)
  • Adapts Schema Registry client code with TryFrom implementations for type conversions
  • Updates field names (e.g., errorput_error/get_error) and hardcodes topic patterns

Reviewed changes

Copilot reviewed 194 out of 194 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
rust/azure_iot_operations_services/gen.sh Updates generation script to use codegen2 with WoT Thing Models and new CLI arguments
rust/azure_iot_operations_services/src/schema_registry.rs Adds TryFrom implementations to convert from generated i32/String types to wrapper enums with validation
rust/azure_iot_operations_services/src/schema_registry/client.rs Updates error handling to use new TryFrom conversions and renamed error fields
rust/azure_iot_operations_services/src/schema_registry/schemaregistry_gen/**/*.rs Regenerated code: enums → const, version bump, field renames, documentation updates
rust/azure_iot_operations_services/src/azure_device_registry/adr_base_gen/**/*.rs Regenerated code: removes MODEL_ID constants, hardcodes topics, enums lose serde renames
rust/azure_iot_operations_services/src/azure_device_registry/device_discovery_gen/**/*.rs Regenerated code: similar patterns to adr_base_gen with enum and topic changes

timtay-microsoft added a commit that referenced this pull request Feb 19, 2026
As seen
[here](https://github.com/Azure/iot-operations-sdks/blob/8833ca95b26bbed007a5f9112b78a48b224d1270/dotnet/src/Azure.Iot.Operations.Services/SchemaRegistry/SchemaRegistry/GetResponseSchema.g.cs#L20)
before the recent DTDL -> WoT conversion, the behavior of the schema
registry generated classes was to define error types like

```csharp
        [JsonPropertyName("error")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public SchemaRegistryError? Error { get; set; } = default;
```

But recent WoT changes made the same fields get defined like

```csharp
        [JsonPropertyName("getError")]
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
        public SchemaRegistryError? GetError { get; set; } = default;
```

which would break deserialization of errors sent from the schema
registry service.

This change alters the SchemaNames.json file such that running code gen
gives the expected output on fields like the above. Then codegen was run
on this branch.

See also #1229 for this same SchemaNames.json file change since it is
needed in Rust as well.

---------

Co-authored-by: timtay-microsoft <timtay-microsoft@users.noreply.github.com>
@vaavva vaavva marked this pull request as draft February 19, 2026 21:07
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.

4 participants