generateApiModels
Convert OpenAPI/Swagger specs into typed TypeScript interfaces or Python dataclasses, pydantic models, and TypedDicts. Resolves $refs, enums, and nested schemas automatically.
Instructions
Generate typed data models from OpenAPI/Swagger spec. Creates TypeScript interfaces/types or Python dataclasses/pydantic/TypedDict from API schemas. Handles $ref resolution, enums, allOf/oneOf, nested objects. Use after loadSwagger to generate model files.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"source": "<source>",
"language": "<language>"
},
"name": "generateApiModels"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| style | No | TypeScript only: 'interface' (default) or 'type' aliases | |
| format | No | Spec format (default: auto) | |
| source | Yes | URL or file path to OpenAPI spec | |
| schemas | No | Generate only these schemas (default: all) | |
| language | Yes | Target language for models | |
| pythonStyle | No | Python only: 'dataclass' (default), 'pydantic', or 'typeddict' | |
| includeEnums | No | Generate enum types (default: true) | |
| includeValidation | No | Include validation constraints as comments (default: false) |