Codegen / TypeScript contract
Generate a TypeScript interface from a paginated JSON response
Start with a paginated article response, generate TypeScript with the default TypeScript settings, and compare the actual multi-file output.
Reproducible trace
Infer interfaces for a paginated article response with nullable cursor metadata.
Input / agents/paginated-articles.json
{
"page": 2,
"nextCursor": null,
"results": [{"id": "p-18", "title": "Field notes", "tags": ["api", "json"]}]
}Operation / JSON to TypeScript
Open the JSON to TypeScript generator, keep the default sample-inferred model, and review nullable fields before using the code.Expected output / GeneratedRoot.ts plus enum files
// codegen-settings.json
{"language":"typescript","enumMode":"enabled","singleFile":false}
// GeneratedRoot.ts
import type { GeneratedRootResultsItem } from './GeneratedRootResultsItem';
export interface GeneratedRoot {
nextCursor: unknown | null;
page: number;
results: GeneratedRootResultsItem[];
}How to use this workflow
- Download or copy the input. The fixture is synthetic and designed for this exact operation.
- Run the operation. Use the linked JSON All-in-One tool, or reproduce the operation in your own environment when the syntax matches.
- Compare the expected output. The expected result is the acceptance target for this fixture, not a general product guarantee.
Notes and limits
- This oracle uses the actual default TypeScript codegen output with enums enabled and separate files.
- Generated interfaces describe this sample; they do not validate runtime API responses. Review nullability, optional fields, and naming before committing generated code.
For broader examples, return to the JSON task workflows hub or browse all JSON tools.