tsp-type-override

Override TypeSpec types with Java-native types using @@alternateType decorators.

2.6k|2.2k|Updated Dec 6, 2011
One-click install
npx skills add https://github.com/Azure/azure-sdk-for-java --skill tsp-type-override
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tsp-type-override
Source: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/.workflow_docs/tsp-type-override
Command: npx skills add https://github.com/Azure/azure-sdk-for-java --skill tsp-type-override

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill allows you to precisely control how TypeSpec models and fields are translated into Java types, ensuring generated code uses the correct Java classes (like OffsetDateTime or DayOfWeek) instead of generic or incorrect ones.

Core Features & Use Cases

  • Type Mapping: Override default TypeSpec-to-Java type mappings for specific fields or entire types.
  • External Type Integration: Use existing Java classes (e.g., from libraries) directly in generated code.
  • Use Case: When a TypeSpec defines a date as a simple string, you can use this Skill to ensure the generated Java code uses java.time.OffsetDateTime for better type safety and usability.

Quick Start

Use the tsp-type-override skill to map the TypeSpec field 'created_at' to the Java type 'utcDateTime'.

Frequently Asked Questions about tsp-type-override

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I override TypeSpec model fields to use specific Java types in generated SDK code?

You can override TypeSpec model fields to use specific Java types by applying `@@alternateType` decorators within `client.java.tsp` files to map generic definitions to precise Java classes like `OffsetDateTime` or `DayOfWeek`.

What is the best way to map a TypeSpec string field to a Java OffsetDateTime type?

To map a TypeSpec string field to a Java OffsetDateTime type, use the `@@alternateType` decorator to override the default mapping and ensure the generated Java code uses the correct specific type for better safety.

Can I use external Java classes directly in TypeSpec API client code generation?

Yes, you can integrate external Java classes directly in generated API client code by mapping TypeSpec models to external Java classes via identity, overriding default type mappings for specific fields or entire types.

When do I need to override default TypeSpec to Java type mappings?

You need to override default TypeSpec to Java type mappings when TypeSpec models have incorrect or too-generic types that should map to specific Java classes, ensuring type safety and usability in generated SDK code.

Does TypeSpec support mapping to built-in scalars for Java SDK development?

Yes, TypeSpec supports mapping to built-in scalars for Java SDK development by using `@@alternateType` decorators in `client.java.tsp` files to replace generic definitions with precise built-in scalar types.