[Epic] [TypeSpec Authoring] Scenario: authoring write typespec by api payload
- Dominant language
- C#
- Stars
- 135
- Forks
- 260
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 143
Description
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;
}
interface Wedget {
createOrUpdateWidget is Operations.LongRunningResourceCreateOrUpdate;
}
```
Contributor guide
Research direction
No files, tests, or entry points are named in the issue. Start by locating the existing TypeSpec authoring flow and its handling of user-provided payloads. Done should include generated models and operations for the example, including nested objects, arrays, enums, optional fields, and primitive type inference.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100