Skip to content

[Epic] [TypeSpec Authoring] Scenario: authoring write typespec by api payload #15844

@chunyu3

Description

@chunyu3

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>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    AzSDK Tools AgentIssue related to the AzSDK Tools Agent.Epicdev inner loopIssues related to our project to enable agentic workflows for the dev inner loop.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions