Support Authoring TypeSpec Code from User-Provided Payload.
When users want to define an API specification in TypeSpec, they often already know the API payload structure. However, writing the corresponding TypeSpec definitions can be challenging, especially for Azure services, because users may not know which Azure TypeSpec templates, decorators, or conventions should be used correctly.
We want to provide an authoring capability that enables users to generate TypeSpec code directly from a provided api payload
The feature should:
- Accept user-provided payloads as input
- Analyze the payload structure and schema
- Generate corresponding TypeSpec models and operations
- Follow existing TypeSpec authoring conventions and best practices
- Support nested objects, arrays, enums, optional fields, and primitive type inference
- Reduce manual effort and improve authoring productivity
Expected Behavior
Prompt:
I want to define a operation 'createOrUpdateWidget' in interface 'Wedget', and the route is /widgets/{widgetName}, and the api payload is
patch /widgets/{widgetName}
{
"name": "Widget",
"location": "eastus",
"tags": {
"env": "test"
}
}
Expected output
model Widget{
name: string;
location: string;
tags?: Record<string>;
}
interface Wedget {
createOrUpdateWidget is Operations.LongRunningResourceCreateOrUpdate<Widget>;
}
Support Authoring TypeSpec Code from User-Provided Payload.
When users want to define an API specification in TypeSpec, they often already know the API payload structure. However, writing the corresponding TypeSpec definitions can be challenging, especially for Azure services, because users may not know which Azure TypeSpec templates, decorators, or conventions should be used correctly.
We want to provide an authoring capability that enables users to generate TypeSpec code directly from a provided api payload
The feature should:
Expected Behavior
Prompt:
I want to define a operation 'createOrUpdateWidget' in interface 'Wedget', and the route is /widgets/{widgetName}, and the api payload is
patch /widgets/{widgetName}
{
"name": "Widget",
"location": "eastus",
"tags": {
"env": "test"
}
}
Expected output