Expand description
TypeScript code generation utilities.
Provides functions to convert JSON Schema to TypeScript types and generate type-safe TypeScript code.
§Examples
use mcp_execution_codegen::common::typescript;
use serde_json::json;
let schema = json!({
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"}
}
});
let ts_type = typescript::json_schema_to_typescript(&schema);Constants§
- MAX_
SCHEMA_ RECURSION_ DEPTH - Maximum nesting depth
json_schema_to_typescriptwill descend into before treating the remainder of a branch as opaque, rather than recursing further.
Functions§
- extract_
properties - Extracts property definitions from JSON Schema for template rendering.
- json_
schema_ to_ typescript - Converts a JSON Schema to TypeScript type definition.
- json_
type_ to_ typescript - Converts JSON Schema type to TypeScript type.
- sanitize_
ts_ identifier - Sanitizes a string for safe use as a TypeScript identifier (e.g. a function, export, or object property name).
- to_
camel_ case - Converts a
snake_casename to camelCase for TypeScript. - to_
pascal_ case - Converts a
snake_casename toPascalCasefor TypeScript types.