jarvisbox

Swagger 2.0 to TypeScript types in browser

Convert a Swagger 2.0 (swagger: "2.0") spec to TypeScript interfaces. Resolves #/definitions/ refs and generates typed paths from response schemas — no Node.js.

Swagger 2.0 (also known as OpenAPI 2.0) is the predecessor to OpenAPI 3.x and is still widely used in enterprise and legacy APIs. Its main structural differences from OpenAPI 3.x are: schemas live under definitions (not components/schemas), request bodies are inline body parameters (not a separate requestBody field), and responses reference schemas directly rather than through a content map.

The OpenAPI to TypeScript browser generator detects Swagger 2.0 by the swagger: "2.0" field and applies the correct parsing strategy: #/definitions/Foo refs resolve to components["schemas"]["Foo"] in the output (using a unified namespace for compatibility), and response schema fields are used directly to produce typed response shapes.

Swagger 2.0 vs OpenAPI 3.x in the generated types

How to use

  1. Paste your Swagger 2.0 JSON or YAML spec into the text area at OpenAPI to TypeScript Types. The tool detects the format from the swagger: "2.0" field automatically.
  2. Click Generate TypeScript. The generator handles definitions, parameter schemas, and response schemas for all paths and HTTP methods.
  3. Download types.d.ts and integrate it into your TypeScript project. The paths interface is compatible with typed fetch helpers.

Related tools

Reportar un problema con esta herramienta