{"_id":"@codejoo/openapi2lang","_rev":"10-b87a812cfba8a5878db651e08891b5f8","name":"@codejoo/openapi2lang","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.0":{"name":"@codejoo/openapi2lang","version":"1.0.0","license":"MIT","_id":"@codejoo/openapi2lang@1.0.0","maintainers":[{"name":"29982416","email":"29982416@qq.com"}],"dist":{"shasum":"327030ee3b40b450f58d4c5717f7ab3db2b4d195","tarball":"https://registry.npmjs.org/@codejoo/openapi2lang/-/openapi2lang-1.0.0.tgz","fileCount":4,"integrity":"sha512-Lf/ESkQ6zg63ulR3q4JIYgTymSIuCk3Cr53Ix9qPZ/KQDPL+aq83560SeOgKmQvWM1a9ScVKrwnD/1nW+HzP4w==","signatures":[{"sig":"MEQCID8/MToLwTWmvAFk8K1kZUsJzPzyx3Et3eax0q+m6ISjAiAiBLDauUEuOgVpDiSb1TTrN3g5qMLzDztoXYGbfEyUGg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":133965},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./package.json":"./package.json"},"gitHead":"ccf972ac5ee14a9163b5ccdc2cabbe692fb9adab","scripts":{"dev":"vp pack --watch","fmt":"vp fmt -c oxfmt.config.ts","lint":"vp lint -c oxlint.config.ts","build":"pnpm run fmt && vp pack","check":"vp fmt -c oxfmt.config.ts --check && vp lint -c oxlint.config.ts"},"_npmUser":{"name":"29982416","email":"29982416@qq.com"},"_npmVersion":"11.6.2","description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"js-yaml":"^4.1.0","quicktype-core":"^23.2.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"catalog:","@types/node":"catalog:","@types/js-yaml":"^4.0.9","@typescript/native-preview":"catalog:"},"_npmOperationalInternal":{"tmp":"tmp/openapi2lang_1.0.0_1777183732034_0.24222744452537648","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@codejoo/openapi2lang","version":"1.0.1","license":"MIT","_id":"@codejoo/openapi2lang@1.0.1","maintainers":[{"name":"29982416","email":"29982416@qq.com"}],"dist":{"shasum":"efee793ded55302c29012d7be4af51cec700f152","tarball":"https://registry.npmjs.org/@codejoo/openapi2lang/-/openapi2lang-1.0.1.tgz","fileCount":4,"integrity":"sha512-SSCGmXlScyYzGzjDi9ywsyDBQgoT0wiUS1D5WbGdK+fv5tNP2PRhMCUnFA+uHi9QzRVv/7i5dIIUlFRmKAYZIg==","signatures":[{"sig":"MEQCIGsBSKYQBvNN7nBMHoGO9T6K3F67NecUOKUuicphCS7zAiAydn+cOyk9qzEf85EK892q5dHPse41Q5SmCg9x7nOeoQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":132338},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./package.json":"./package.json"},"gitHead":"ccf972ac5ee14a9163b5ccdc2cabbe692fb9adab","scripts":{"dev":"vp pack --watch","fmt":"vp fmt -c oxfmt.config.ts","lint":"vp lint -c oxlint.config.ts","build":"pnpm run fmt && vp pack","check":"vp fmt -c oxfmt.config.ts --check && vp lint -c oxlint.config.ts"},"_npmUser":{"name":"29982416","email":"29982416@qq.com"},"_npmVersion":"11.6.2","description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"js-yaml":"^4.1.0","quicktype-core":"^23.2.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"catalog:","@types/node":"catalog:","@types/js-yaml":"^4.0.9","@typescript/native-preview":"catalog:"},"_npmOperationalInternal":{"tmp":"tmp/openapi2lang_1.0.1_1777184617432_0.5085787219152531","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@codejoo/openapi2lang","version":"1.0.2","license":"MIT","_id":"@codejoo/openapi2lang@1.0.2","maintainers":[{"name":"29982416","email":"29982416@qq.com"}],"dist":{"shasum":"26deaf2f54fead2a4377e30f7b17373417be6452","tarball":"https://registry.npmjs.org/@codejoo/openapi2lang/-/openapi2lang-1.0.2.tgz","fileCount":5,"integrity":"sha512-ZAfVxaKKluEIpoCruGF5q2+tz5urERtcP6vAnJrng7IPo7Rg+Q98JURKNZg0JRhvJoaxgpux6uPAIRZRO/+ApA==","signatures":[{"sig":"MEUCIDufpyxJwowTvxVvJkqzyJeY9gwx4YmonV33bXXC7z/6AiEA52El1Z5oly3O/wzbagbBypnq0n95ZiCdivTTLrZzsMM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":155046},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./package.json":"./package.json"},"gitHead":"3d0277f1326934cb1e7ba839a4581db8a033be11","scripts":{"dev":"vp pack --watch","fmt":"vp fmt -c oxfmt.config.ts","lint":"vp lint -c oxlint.config.ts","build":"pnpm run fmt && vp pack","check":"vp fmt -c oxfmt.config.ts --check && vp lint -c oxlint.config.ts"},"_npmUser":{"name":"29982416","email":"29982416@qq.com"},"_npmVersion":"11.6.2","description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"js-yaml":"^4.1.0","quicktype-core":"^23.2.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"catalog:","@types/node":"catalog:","@types/js-yaml":"^4.0.9","@typescript/native-preview":"catalog:"},"_npmOperationalInternal":{"tmp":"tmp/openapi2lang_1.0.2_1777184752435_0.1466700313928624","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@codejoo/openapi2lang","version":"1.0.3","license":"MIT","_id":"@codejoo/openapi2lang@1.0.3","maintainers":[{"name":"29982416","email":"29982416@qq.com"}],"dist":{"shasum":"31244d8a573c29be585dd4711880f8cf5ef706cd","tarball":"https://registry.npmjs.org/@codejoo/openapi2lang/-/openapi2lang-1.0.3.tgz","fileCount":5,"integrity":"sha512-bgVerARJG1LN/1d+wxBTY9YuEkCOuj/QGU0J9cuCK5u2JGnrpl8ePbSgLp924KAxN0/oxwDNz0fLK+HZHTpC5A==","signatures":[{"sig":"MEUCIDmdMWPGLHi9gsMxEvdLHeucRNZk/ld6WaqValMRKNrWAiEA1Wcs9vIzihfSUGuSHaYH6KLShd1D548YVfGMzQFpCX4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":156688},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./package.json":"./package.json"},"gitHead":"3d0277f1326934cb1e7ba839a4581db8a033be11","scripts":{"dev":"vp pack --watch","fmt":"vp fmt -c oxfmt.config.ts","lint":"vp lint -c oxlint.config.ts","build":"pnpm run fmt && vp pack","check":"vp fmt -c oxfmt.config.ts --check && vp lint -c oxlint.config.ts"},"_npmUser":{"name":"29982416","email":"29982416@qq.com"},"_npmVersion":"11.6.2","description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"js-yaml":"^4.1.0","quicktype-core":"^23.2.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"catalog:","@types/node":"catalog:","@types/js-yaml":"^4.0.9","@typescript/native-preview":"catalog:"},"_npmOperationalInternal":{"tmp":"tmp/openapi2lang_1.0.3_1777184885352_0.6730341355639524","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@codejoo/openapi2lang","version":"1.0.4","license":"MIT","_id":"@codejoo/openapi2lang@1.0.4","maintainers":[{"name":"29982416","email":"29982416@qq.com"}],"dist":{"shasum":"d12de818f229325067044e90ae97183a3f5fbbcb","tarball":"https://registry.npmjs.org/@codejoo/openapi2lang/-/openapi2lang-1.0.4.tgz","fileCount":5,"integrity":"sha512-gByHzAXsh9HBoauFuHOObhi1ObriYSRWDNXOoHapwwcqvS5zXWnjac3vCKbtE28BDWPvXIMz9SzTMEH9sn6rmA==","signatures":[{"sig":"MEUCIEJDkFYBmWFcuN8lj1x/cuwadSeY4X25QGUcEjntLzSaAiEA9AfGTWt6gxqLUUHvUvPEKNc4iXN6ca03ARnlLa148cw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":156688},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./package.json":"./package.json"},"gitHead":"3d0277f1326934cb1e7ba839a4581db8a033be11","scripts":{"dev":"vp pack --watch","fmt":"vp fmt -c oxfmt.config.ts","lint":"vp lint -c oxlint.config.ts","build":"pnpm run fmt && vp pack","check":"vp fmt -c oxfmt.config.ts --check && vp lint -c oxlint.config.ts"},"_npmUser":{"name":"29982416","email":"29982416@qq.com"},"_npmVersion":"11.6.2","description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"js-yaml":"^4.1.0","quicktype-core":"^23.2.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"catalog:","@types/node":"catalog:","@types/js-yaml":"^4.0.9","@typescript/native-preview":"catalog:"},"_npmOperationalInternal":{"tmp":"tmp/openapi2lang_1.0.4_1777184961622_0.6975231999215812","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@codejoo/openapi2lang","version":"1.0.6","license":"MIT","_id":"@codejoo/openapi2lang@1.0.6","maintainers":[{"name":"29982416","email":"29982416@qq.com"}],"dist":{"shasum":"ca1d8fbdc0f951a96c8585b67ee66d7a7ab17ee3","tarball":"https://registry.npmjs.org/@codejoo/openapi2lang/-/openapi2lang-1.0.6.tgz","fileCount":5,"integrity":"sha512-OCCvzeFm/ICINWXA/Mt3wo2TPF5s5jD+FB0BZYibu14xQmJm+CMEpFLjOOF6oMYSfK9xq92kkEuvgIWhUjTPPg==","signatures":[{"sig":"MEUCIF3PHSN4QRjcCPP5Tj44FhSosEk26PoljBAl5tHJGU8HAiEA5gVzhKjpICLVD8uUtw5fmISdMLL86E+aO/yprO6VasY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":156786},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./package.json":"./package.json"},"gitHead":"3d0277f1326934cb1e7ba839a4581db8a033be11","scripts":{"dev":"vp pack --watch","fmt":"vp fmt -c oxfmt.config.ts","lint":"vp lint -c oxlint.config.ts","build":"pnpm run fmt && vp pack","check":"vp fmt -c oxfmt.config.ts --check && vp lint -c oxlint.config.ts"},"_npmUser":{"name":"29982416","email":"29982416@qq.com"},"_npmVersion":"11.6.2","description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"js-yaml":"^4.1.0","quicktype-core":"^23.2.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"catalog:","@types/node":"catalog:","@types/js-yaml":"^4.0.9","@typescript/native-preview":"catalog:"},"_npmOperationalInternal":{"tmp":"tmp/openapi2lang_1.0.6_1777185409808_0.7883220481747855","host":"s3://npm-registry-packages-npm-production"}},"1.0.7":{"name":"@codejoo/openapi2lang","version":"1.0.7","keywords":["api","code-generation","codegen","dart","openapi","openapi3","quicktype","rest","schema","swagger","swagger2","type-generation","types","typescript"],"author":{"name":"icodejoo"},"license":"MIT","_id":"@codejoo/openapi2lang@1.0.7","maintainers":[{"name":"29982416","email":"29982416@qq.com"}],"homepage":"https://github.com/icodejoo/codejoo/tree/main/apps/openapi#readme","bugs":{"url":"https://github.com/icodejoo/codejoo/issues"},"dist":{"shasum":"5756180bc89f032b1bb893c93971160a754b325e","tarball":"https://registry.npmjs.org/@codejoo/openapi2lang/-/openapi2lang-1.0.7.tgz","fileCount":4,"integrity":"sha512-xihlduGnCsaWvLP9pozP7Mb0J05NFAo8PHQlehpwCxAJa5GbIlzwyomlp8XTPcgRaUOrO+UZqhA9QvmKGDstLw==","signatures":[{"sig":"MEQCIF6s+GovNS2f+5Z2PJuVq86AkwtOe1uj7U/BCHp8fbF9AiAquvuHJ7NQRGZqVkHmm4Rz3CKQPVtD5pJQOgTqvKCC5g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":140514},"main":"./dist/index.mjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./package.json":"./package.json"},"gitHead":"873fd1d14498b9f3fc24f8f106af8b8f6f1b4d5b","scripts":{"dev":"vp pack --watch","fmt":"vp fmt -c oxfmt.config.ts","pub":"pnpm run build && pnpm version patch --no-git-tag-version && git add package.json && git commit -m \"chore: release openapi2lang\" && npm publish","lint":"vp lint -c oxlint.config.ts","build":"pnpm run fmt && vp pack","check":"vp fmt -c oxfmt.config.ts --check && vp lint -c oxlint.config.ts"},"_npmUser":{"name":"29982416","email":"29982416@qq.com"},"repository":{"url":"git+https://github.com/icodejoo/codejoo.git","type":"git","directory":"apps/openapi"},"_npmVersion":"11.6.2","description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","directories":{},"_nodeVersion":"24.11.1","dependencies":{"js-yaml":"^4.1.0","quicktype-core":"^23.2.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"catalog:","@types/node":"catalog:","@types/js-yaml":"^4.0.9","@typescript/native-preview":"catalog:"},"_npmOperationalInternal":{"tmp":"tmp/openapi2lang_1.0.7_1782135110327_0.015959060704537897","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-04-26T06:08:51.901Z","modified":"2026-07-16T22:57:24.780Z","1.0.0":"2026-04-26T06:08:52.205Z","1.0.1":"2026-04-26T06:23:37.565Z","1.0.2":"2026-04-26T06:25:52.577Z","1.0.3":"2026-04-26T06:28:05.486Z","1.0.4":"2026-04-26T06:29:21.764Z","1.0.5":"2026-04-26T06:31:41.846Z","1.0.6":"2026-04-26T06:36:49.955Z","1.0.7":"2026-06-22T13:31:50.468Z"},"bugs":{"url":"https://github.com/icodejoo/codejoo/issues"},"author":{"name":"icodejoo"},"license":"MIT","homepage":"https://github.com/icodejoo/codejoo/tree/main/apps/openapi#readme","keywords":["api","code-generation","codegen","dart","openapi","openapi3","quicktype","rest","schema","swagger","swagger2","type-generation","types","typescript"],"repository":{"url":"git+https://github.com/icodejoo/codejoo.git","type":"git","directory":"apps/openapi"},"description":"Convert an OpenAPI 3.x / Swagger 2.0 document into type declarations for TypeScript, Dart and 25+ other languages.","maintainers":[{"email":"29982416@qq.com","name":"29982416"},{"email":"gapkukb@gmail.com","name":"icodejoo"}],"readme":"# @codejoo/openapi2lang\n\n> 🌐 **Languages:** **English** · [中文](https://github.com/gapkukb/codejoo/blob/main/apps/openapi/README_zh.md)\n\nConverts an OpenAPI 3.x (or Swagger 2.0) document into type declarations for TypeScript, Dart, and 25+ other languages. Powered by [quicktype-core](https://github.com/quicktype/quicktype).\n\n---\n\n## Table of Contents\n\n- [@codejoo/openapi2lang](#codejooopenapi2lang)\n  - [Table of Contents](#table-of-contents)\n  - [1. Installation](#1-installation)\n  - [2. Quick Start](#2-quick-start)\n  - [3. generate() API](#3-generate-api)\n  - [4. configureBase() Options](#4-configurebase-options)\n  - [5. TypeScript Output](#5-typescript-output)\n    - [5.1 Generated File Structure](#51-generated-file-structure)\n    - [5.2 Namespace Layout](#52-namespace-layout)\n      - [Request type generation rules](#request-type-generation-rules)\n    - [5.3 PathRefs — the key data structure](#53-pathrefs--the-key-data-structure)\n  - [6. Type-Safe Fetch with `Request<PathRefs>`](#6-type-safe-fetch-with-requestpathrefs)\n    - [6.1 Build the request wrapper](#61-build-the-request-wrapper)\n    - [6.2 Auto-inferred call sites](#62-auto-inferred-call-sites)\n    - [6.3 Explicit generics: override or escape](#63-explicit-generics-override-or-escape)\n    - [6.4 Compile-time errors caught automatically](#64-compile-time-errors-caught-automatically)\n    - [6.5 Optional: build shortcut methods on top](#65-optional-build-shortcut-methods-on-top)\n  - [7. configureTypescript() Options](#7-configuretypescript-options)\n    - [7.1 base options](#71-base-options)\n    - [7.2 primary options (quicktype renderer)](#72-primary-options-quicktype-renderer)\n    - [7.3 others options](#73-others-options)\n    - [7.4 Example: use `interface` instead of `type`](#74-example-use-interface-instead-of-type)\n    - [7.5 Example: infer date-time strings as `Date`](#75-example-infer-date-time-strings-as-date)\n  - [8. Dart Output](#8-dart-output)\n    - [8.1 base options](#81-base-options)\n    - [8.2 primary options](#82-primary-options)\n    - [8.3 others options](#83-others-options)\n    - [8.4 Example: freezed](#84-example-freezed)\n  - [9. Other Languages](#9-other-languages)\n  - [10. Custom Emitters](#10-custom-emitters)\n  - [11. Inference Flags](#11-inference-flags)\n  - [12. Pipeline Architecture](#12-pipeline-architecture)\n\n---\n\n## 1. Installation\n\n```bash\npnpm add @codejoo/openapi2lang\n# or\nnpm install @codejoo/openapi2lang\n```\n\n> **Node requirement:** Node.js 16 or above (ESM package).\n\n---\n\n## 2. Quick Start\n\nCreate a script (e.g. `scripts/gen-types.mjs`) in your project root:\n\n```js\nimport { generate, configureBase, configureTypescript, configureDart } from \"@codejoo/openapi2lang\";\n\nawait generate(\n  configureBase({\n    source: \"https://petstore3.swagger.io/api/v3/openapi.json\",\n    // or a local file:\n    // source: './openapi.yaml',\n  }),\n  [\n    configureTypescript(), // outputs to ./types/\n    configureDart(), // outputs to ./types/dart/\n  ],\n);\n```\n\nRun it:\n\n```bash\nnode scripts/gen-types.mjs\n```\n\nConsole output (all absolute paths so you know exactly where files landed):\n\n```\n[openapi2lang] Loading OpenAPI: https://petstore3.swagger.io/api/v3/openapi.json\n[openapi2lang] Building mega-schema...\n[openapi2lang] components: 5 | ops: 19 | definitions: 42\n[openapi2lang] Running quicktype for language: typescript\n  Written: /your/project/types/response.d.ts\n  Written: /your/project/types/request.d.ts\n  Written: /your/project/types/paths.d.ts\n[openapi2lang] Running quicktype for language: dart\n  Written: /your/project/types/dart/models.dart\n  Written: /your/project/types/dart/paths.dart\n[openapi2lang] Done.\n```\n\n---\n\n## 3. generate() API\n\n```ts\nfunction generate(base: BaseConfig, langs: LangConfig[]): Promise<void>;\n```\n\n| Parameter | Type           | Description                                                      |\n| --------- | -------------- | ---------------------------------------------------------------- |\n| `base`    | `BaseConfig`   | Source file / preprocessing options shared across all languages  |\n| `langs`   | `LangConfig[]` | One entry per language; each built with a `configure*()` factory |\n\n`generate()` resolves `process.cwd()` as the project root. All output `dir` paths are resolved relative to it.\n\n---\n\n## 4. configureBase() Options\n\n```ts\nconfigureBase(input: ConfigureBaseInput): BaseConfig\n```\n\n```ts\ninterface ConfigureBaseInput {\n  /** OpenAPI source: http/https URL or local file path (.json / .yaml / .yml) */\n  source: string;\n\n  /**\n   * When an object schema has explicit `properties` but no `additionalProperties`,\n   * inject `additionalProperties: false` to make quicktype produce a closed type.\n   * Default: true\n   */\n  strictObjects?: boolean;\n\n  /**\n   * Order in which HTTP methods are processed per path.\n   * Affects field order in PathRefs and priority when two ops share the same name.\n   * Default: ['get', 'post', 'put', 'delete', 'patch', 'options', 'head']\n   */\n  httpMethodOrder?: readonly string[];\n\n  /**\n   * How to disambiguate names when two schemas would produce the same identifier.\n   * Default: (base, n) => `${base}$${n}`  →  \"Pet$1\", \"Pet$2\", …\n   */\n  conflictSuffix?: (base: string, n: number) => string;\n}\n```\n\n---\n\n## 5. TypeScript Output\n\n### 5.1 Generated File Structure\n\n`configureTypescript()` outputs **three declaration files**:\n\n```\ntypes/\n├── response.d.ts   — All component schemas + extracted enums + inline response aliases\n├── request.d.ts    — One flattened type per operation (all params + body merged, no nesting)\n└── paths.d.ts      — model.Paths union type + model.PathRefs index interface\n```\n\nAll three files use `declare namespace`, so TypeScript merges them automatically — no imports needed anywhere in the consuming codebase.\n\n### 5.2 Namespace Layout\n\n```\nmodel\n├── Pet                        ← component schema\n├── Order\n├── ApiResponse\n├── PetStatus                  ← enum lifted from an inline schema\n├── GetPetByIdInlineResponse   ← inline response alias (auto-named)\n│\n├── req\n│   ├── GetPetById             ← { petId: number }   (path-only, no body)\n│   ├── UpdatePetWithForm      ← { petId: number; name?: string; status?: string }  (path + form body inlined)\n│   ├── AddPet                 ← extends model.Pet {}              (pure ref body, no extra params)\n│   ├── UpdateUser             ← extends model.User { username: string }  (ref body + path param)\n│   └── …\n│\n├── Paths                      ← string literal union of all declared paths\n└── PathRefs                   ← index interface (see §5.3)\n```\n\n#### Request type generation rules\n\n| Body type               | Extra params        | Generated shape                                                 |\n| ----------------------- | ------------------- | --------------------------------------------------------------- |\n| none                    | path / query params | `type X = { param1: T; param2?: T }`                            |\n| inline object           | path / query params | All fields merged flat: `type X = { bodyField1: T; param1: T }` |\n| `$ref` to a component   | none                | `interface X extends model.Y {}`                                |\n| `$ref` to a component   | path / query params | `interface X extends model.Y { param1: T; param2?: T }`         |\n| complex (allOf / oneOf) | any                 | `type X = { body: ComplexType; param1: T }`                     |\n\nThis means the consuming code never deals with a nested `body:` field for JSON ref bodies — all parameters are at the same level.\n\n### 5.3 PathRefs — the key data structure\n\n`model.PathRefs` is the index interface that drives all type-safe fetch inference:\n\n```ts\ndeclare namespace model {\n  interface PathRefs {\n    \"/pet/{petId}\": {\n      get: [response: model.Pet, request: model.req.GetPetById];\n      delete: [response: unknown, request: model.req.DeletePet];\n    };\n    \"/store/order\": {\n      post: [response: model.Order, request: model.req.PlaceOrder];\n    };\n    \"/pet/findByStatus\": {\n      get: [response: Array<model.Pet>, request: model.req.FindPetsByStatus];\n    };\n    // … every path × method combination from the OpenAPI spec\n  }\n}\n```\n\nEach `(path, method)` pair maps to a **labeled tuple `[response, request]`**:\n\n- Index `[0]` — the success response type\n- Index `[1]` — the flattened request payload type (all path params, query params, and body fields in one object)\n\nUsing a tuple (not an object) means we can read `[0]` / `[1]` directly without `extends ... infer ...`, which is significantly cheaper for the TypeScript compiler on large schemas.\n\n---\n\n## 6. Type-Safe Fetch with `Request<PathRefs>`\n\nOnce the three `.d.ts` files are on disk and included in `tsconfig.json`, wire them up to your fetch layer through the `Request` generic exported from this package. You write the runtime once; the types are derived from the generated `PathRefs`.\n\n### 6.1 Build the request wrapper\n\n```ts\n// src/api/client.ts\nimport type { Request } from \"@codejoo/openapi2lang\";\n\nasync function impl(method: string, path: string, body?: unknown): Promise<unknown> {\n  const init: RequestInit = { method: method.toUpperCase() };\n  let url = path;\n\n  if (body !== undefined) {\n    if (method.toLowerCase() === \"get\") {\n      // serialize body as query string for GET\n      const params = new URLSearchParams(body as Record<string, string>).toString();\n      if (params) url += (url.includes(\"?\") ? \"&\" : \"?\") + params;\n    } else {\n      init.headers = { \"Content-Type\": \"application/json\" };\n      init.body = JSON.stringify(body);\n    }\n  }\n\n  const res = await fetch(url, init);\n  return res.json();\n}\n\n// loosely-typed `impl` is upgraded to a fully type-safe API by the cast.\nexport const request = impl as Request<model.PathRefs>;\n```\n\n`Request<R>` produces (greatly simplified):\n\n```ts\nfunction request<R = unknown, Q = unknown, M extends Method, P extends PathHint<M>>(method: M, path: P, ...args: ResolvedBody<Q, M, P>): Promise<ResolvedRes<R, M, P>>;\n```\n\n- **`M`, `P`** — inferred from the call-site arguments\n- **`R`, `Q`** — explicit type parameters that override spec inference (escape hatch for mock / undeclared endpoints)\n- **`...args`** — `[body: X]` (required) or `[body?: undefined]` (optional) depending on the spec's request tuple\n- **return type** — pulled from the spec's response slot, or `any` if `path`/`method` not declared\n\n### 6.2 Auto-inferred call sites\n\n```ts\nimport { request } from \"@/api/client\";\n\n// ✅ method + path inferred; payload type checked against spec\nconst pet = await request(\"get\", \"/pet/{petId}\", { petId: 1 });\n//    ^ Promise<model.Pet>\n\n// ✅ POST with body\nconst order = await request(\"post\", \"/store/order\", {\n  id: 10,\n  petId: 1,\n  quantity: 2,\n  status: \"placed\",\n  complete: false,\n});\n//    ^ Promise<model.Order>\n\n// ✅ Array response\nconst pets = await request(\"get\", \"/pet/findByStatus\", { status: \"available\" });\n//    ^ Promise<Array<model.Pet>>\n\n// ✅ Path param + body field flat (no nested `body:` wrapper)\nawait request(\"put\", \"/user/{username}\", {\n  username: \"john\", // path parameter (extends-injected)\n  email: \"john@example.com\", // body field (inherited from model.User)\n});\n```\n\n### 6.3 Explicit generics: override or escape\n\n`request<R, Q>(...)` lets you bypass spec inference. Useful for endpoints that don't appear in the spec (mocks, third-party, not yet shipped).\n\n```ts\n// path is in spec → R/Q auto-pulled from spec\nawait request(\"get\", \"/pet/{petId}\", { petId: 1 });\n\n// path NOT in spec, no generics → R = any, Q = any\nconst r = await request(\"get\", \"/internal/healthcheck\");\n\n// path NOT in spec, explicit R → response is Pet, body unchecked\nconst c = await request<model.Pet>(\"get\", \"/x\");\n\n// explicit R + Q → both body and response are user-typed; forces body required\nconst d = await request<model.Pet, string>(\"post\", \"/x\", \"body-as-string\");\n```\n\nType rules in priority order:\n\n1. Explicit `<R, Q>` wins over spec\n2. Otherwise spec inference (response from `PathRefs[P][M][0]`, body from `PathRefs[P][M][1]`)\n3. Spec misses → response/body fall back to `any`\n4. Spec request tuple `[]` → body optional; `[payload: X]` → body required\n\n### 6.4 Compile-time errors caught automatically\n\n```ts\n// ❌ spec marks body as required for GET /pet/findByStatus\n// @ts-expect-error - body required\nawait request(\"get\", \"/pet/findByStatus\");\n\n// ❌ missing required field\nawait request(\"get\", \"/pet/{petId}\", {});\n// Error: Property 'petId' is missing in type '{}'\n//        but required in type 'model.req.GetPetById'\n\n// ❌ wrong field type\nawait request(\"get\", \"/pet/{petId}\", { petId: \"one\" });\n// Error: Type 'string' is not assignable to type 'number'\n\n// ❌ PUT path param missing\nawait request(\"put\", \"/user/{username}\", { email: \"john@example.com\" });\n// Error: Property 'username' is missing in type '...'\n//        but required in type 'model.req.UpdateUser'\n```\n\n### 6.5 Optional: build shortcut methods on top\n\nIf you prefer `get(path, body)` over `request(\"get\", path, body)`, compose with the `OpenApi<R>` type also exported from this package — it pre-computes lookup tables (`Method`, `MethodOf`, `PathsOf`, `Res`, `Body`) so you don't reinvent them.\n\n```ts\nimport type { OpenApi } from \"@codejoo/openapi2lang\";\nimport { request } from \"./client\";\n\ntype Api = OpenApi<model.PathRefs>;\n// Api[\"PathsOf\"][\"get\"] → '/pet/{petId}' | '/pet/findByStatus' | ...\n\nfunction buildHttpMethod<const M extends Api[\"Method\"]>(method: M) {\n  return <P extends Api[\"PathsOf\"][M] | (string & {})>(path: P, ...body: P extends keyof Api[\"Body\"] ? (M extends keyof Api[\"Body\"][P] ? Api[\"Body\"][P][M] : [body?: any]) : [body?: any]) =>\n    request(method as never, path as never, ...(body as never[]));\n}\n\nexport const get = buildHttpMethod(\"get\");\nexport const post = buildHttpMethod(\"post\");\nexport const put = buildHttpMethod(\"put\");\nexport const del = buildHttpMethod(\"delete\");\nexport const patch = buildHttpMethod(\"patch\");\n\n// Usage is even shorter:\nconst pet = await get(\"/pet/{petId}\", { petId: 1 });\n//    ^ Promise<model.Pet>\n```\n\nThe `const M extends Api[\"Method\"]` modifier on `buildHttpMethod` ensures `'get'` is never widened to `string` (otherwise `PathsOf[string]` would produce `never` and break path autocompletion).\n\n> `(string & {})` is a TypeScript trick: widens to any string at runtime but prevents the compiler from collapsing the union, so IDE autocompletion still lists the known literal paths. Drop it from `LoosePath<M>` to disable the \"any path\" escape hatch.\n\n---\n\n## 7. configureTypescript() Options\n\n```ts\nconfigureTypescript(input?: ConfigureTsInput): TsLangConfig\n```\n\nAll fields are optional. Pass only what you want to override.\n\n### 7.1 base options\n\n```ts\nconfigureTypescript({\n  base: {\n    dir: \"./types\", // Output directory (relative to project root). Default: './types'\n    responseFile: \"response.d.ts\", // Default: 'response.d.ts'\n    requestFile: \"request.d.ts\", // Default: 'request.d.ts'\n    pathsFile: \"paths.d.ts\", // Default: 'paths.d.ts'\n    rootNamespace: \"model\", // declare namespace name. Default: 'model'\n    requestNamespace: \"req\", // Sub-namespace for request types. Default: 'req'\n    fileHeader: \"// auto-generated\\n\\n\", // Prepended to every output file\n    inferenceFlags: { inferEnums: true }, // Override specific flags (merged, not replaced)\n  },\n});\n```\n\n### 7.2 primary options (quicktype renderer)\n\n```ts\nconfigureTypescript({\n  primary: {\n    \"just-types\": true, // Types only, no runtime converters. Default: true\n    \"runtime-typecheck\": false, // Runtime JSON validation. Default: false\n    \"nice-property-names\": false, // Rename snake_case → camelCase. Default: false\n    \"explicit-unions\": false, // Named aliases for union types. Default: false\n    \"prefer-unions\": true, // String literal unions instead of enums. Default: true\n    \"prefer-types\": true, // type aliases instead of interface. Default: true\n    \"prefer-const-values\": false, // Singleton enums → string literals. Default: false\n    readonly: false, // Add readonly to all fields. Default: false\n    \"acronym-style\": \"original\", // 'original' | 'pascal' | 'camel' | 'lowerCase'. Default: 'original'\n  },\n});\n```\n\n### 7.3 others options\n\n```ts\nconfigureTypescript({\n  others: {\n    \"runtime-typecheck-ignore-unknown-properties\": false, // Default: false\n    \"raw-type\": \"json\", // Input kind for converters: 'json' | 'any'. Default: 'json'\n  },\n});\n```\n\n### 7.4 Example: use `interface` instead of `type`\n\n```ts\nconfigureTypescript({\n  primary: { \"prefer-types\": false },\n});\n```\n\n### 7.5 Example: infer date-time strings as `Date`\n\n```ts\nconfigureTypescript({\n  base: {\n    inferenceFlags: { inferDateTimes: true },\n  },\n});\n```\n\n---\n\n## 8. Dart Output\n\n```ts\nconfigureDart(input?: ConfigureDartInput): DartLangConfig\n```\n\nOutputs two files:\n\n| File          | Content                                                  |\n| ------------- | -------------------------------------------------------- |\n| `models.dart` | All model classes with `fromJson` / `toJson`             |\n| `paths.dart`  | `PathRefs` class with typed `PathOp<Req, Res>` constants |\n\n### 8.1 base options\n\n```ts\nconfigureDart({\n  base: {\n    dir: \"./types/dart\", // Default: './types/dart'\n    modelsFile: \"models.dart\", // Default: 'models.dart'\n    pathsFile: \"paths.dart\", // Default: 'paths.dart'\n    pathsClassName: \"PathRefs\", // Default: 'PathRefs'\n  },\n});\n```\n\n### 8.2 primary options\n\n```ts\nconfigureDart({\n  primary: {\n    \"null-safety\": true, // Null-safe syntax (String?). Default: true\n    \"just-types\": false, // Skip fromJson/toJson. Default: false\n    \"coders-in-class\": false, // Embed serializers inside class. Default: false\n    \"required-props\": false, // All fields required. Default: false\n    \"final-props\": true, // All fields final. Default: true\n    \"copy-with\": false, // Generate copyWith(). Default: false\n  },\n});\n```\n\n### 8.3 others options\n\n```ts\nconfigureDart({\n  others: {\n    \"from-map\": false, // Rename fromJson→fromMap, toJson→toMap. Default: false\n    \"use-freezed\": false, // @freezed compatible output. Default: false\n    \"use-hive\": false, // @HiveType / @HiveField annotations. Default: false\n    \"use-json-annotation\": false, // @JsonKey annotations for json_serializable. Default: false\n    \"part-name\": \"\", // part 'X.dart'; name for freezed / json_serializable. Default: ''\n  },\n});\n```\n\n### 8.4 Example: freezed\n\n```ts\nconfigureDart({\n  others: {\n    \"use-freezed\": true,\n    \"part-name\": \"models\",\n  },\n});\n```\n\n---\n\n## 9. Other Languages\n\n28 languages are available. All follow the same pattern:\n\n```ts\nimport {\n  configureJava,\n  configureKotlin,\n  configureSwift,\n  configureGo,\n  configurePython,\n  configureCSharp,\n  configureRust,\n  configureRuby,\n  configurePhp,\n  configureCpp,\n  configureCJson,\n  configureObjectiveC,\n  configureScala3,\n  configureSmithy4s,\n  configureCrystal,\n  configureElixir,\n  configureHaskell,\n  configureElm,\n  configurePike,\n  configureFlow,\n  configureJavascript,\n  configureJavascriptPropTypes,\n  configureTypescriptZod,\n  configureTypescriptEffectSchema,\n  configureJsonSchema,\n} from \"@codejoo/openapi2lang\";\n\nawait generate(configureBase({ source: \"./openapi.yaml\" }), [\n  configureTypescript(),\n  configureKotlin({ base: { dir: \"./src/main/kotlin/api\" } }),\n  configureSwift({ base: { dir: \"./Sources/API\" } }),\n  configureGo({ base: { dir: \"./internal/api\" } }),\n]);\n```\n\nLanguages without a custom emitter write a single file specified by `base.modelsFile`:\n\n```ts\nconfigureJava({\n  base: {\n    dir: \"./src/main/java/com/example/api\",\n    modelsFile: \"Models.java\",\n  },\n});\n```\n\n---\n\n## 10. Custom Emitters\n\nAn emitter is a function called after quicktype runs, receiving the raw quicktype output and the full OpenAPI metadata. Return an array of `{ filename, content }` to write multiple files.\n\n```ts\nimport type { EmitContext, EmitOutput, LangConfig } from \"@codejoo/openapi2lang\";\n\nfunction myEmitter(ctx: EmitContext): EmitOutput[] {\n  const { raw, meta, cfg } = ctx;\n\n  // meta.ops        — array of all operations\n  // meta.reqInfoOf  — Map<opKey, ReqInfo>\n  // meta.schema     — the merged JSON Schema fed to quicktype\n  // raw             — quicktype's raw text output\n\n  return [\n    { filename: \"models.ts\", content: `// generated\\n${raw}` },\n    { filename: \"paths.ts\", content: generatePathsFile(meta) },\n  ];\n}\n\nconst myLangConfig: LangConfig = {\n  base: {\n    lang: \"typescript\",\n    dir: \"./out\",\n    fileHeader: \"\",\n    inferenceFlags: DEFAULT_INFERENCE_FLAGS,\n  },\n  primary: {},\n  others: {},\n  emitter: myEmitter,\n};\n\nawait generate(configureBase({ source: \"...\" }), [myLangConfig]);\n```\n\n`EmitContext` gives you full access to:\n\n| Field         | Type               | Description                                                       |\n| ------------- | ------------------ | ----------------------------------------------------------------- |\n| `raw`         | `string`           | Raw quicktype output (`result.lines.join('\\n')`)                  |\n| `meta`        | `MegaSchemaResult` | All ops, component names, req/response maps                       |\n| `inputData`   | `InputData`        | The InputData passed to quicktype (re-use to run quicktype again) |\n| `schemaInput` | `JSONSchemaInput`  | The JSONSchemaInput (useful for adding more sources)              |\n| `cfg`         | `LangConfig`       | The full language config (cast to your concrete type as needed)   |\n\n---\n\n## 11. Inference Flags\n\nInference flags control how quicktype constructs its internal type graph. Each language config has its own independent set — changing one language's flags does not affect others.\n\n```ts\ninterface InferenceFlags {\n  inferMaps: boolean; // Detect object → Map<string, V>. Default: false\n  inferEnums: boolean; // Detect string unions → enum. Default: false\n  inferUuids: boolean; // Detect UUID strings → uuid type. Default: false\n  inferDateTimes: boolean; // Detect ISO-8601 strings → Date. Default: false\n  inferIntegerStrings: boolean; // Detect numeric strings → number. Default: false\n  inferBooleanStrings: boolean; // Detect \"true\"/\"false\" strings → boolean. Default: false\n  combineClasses: boolean; // Merge structurally identical classes. Default: true\n  ignoreJsonRefs: boolean; // Ignore $ref cycles / self-references. Default: true\n}\n```\n\nOverride specific flags per language:\n\n```ts\nconfigureTypescript({\n  base: {\n    inferenceFlags: {\n      inferDateTimes: true, // format: date-time → Date\n      inferEnums: true, // repeated string values → enum\n    },\n  },\n});\n```\n\n---\n\n## 12. Pipeline Architecture\n\n```\ngenerate(base, langs)\n      │\n      ├─ loadOpenAPI(source)          — fetch / read file, convert Swagger 2.0 → OpenAPI 3.0\n      │\n      ├─ buildMegaSchema(doc, base)   — merge all schemas into one root JSON Schema\n      │         │                       extract ops, req types, response refs\n      │         └── MegaSchemaResult\n      │                 ├── schema          (fed to quicktype)\n      │                 ├── componentNames\n      │                 ├── ops\n      │                 ├── reqInfoOf\n      │                 └── responseRefOf\n      │\n      └─ for each LangConfig:\n              │\n              ├─ JSONSchemaInput.addSource(mega-schema)\n              ├─ quicktype({ inputData, lang, rendererOptions, ...inferenceFlags })\n              │         → raw string output\n              │\n              └─ if emitter → emitter(ctx)   — post-process (split files, rewrite refs, …)\n                 else       → defaultEmit()  — strip quicktype header, write modelsFile\n```\n\nThe TypeScript emitter (`emitTypescript`) performs these post-processing steps on quicktype's raw output:\n\n1. `T[]` → `Array<T>` for readability\n2. Enum-like blocks lifted to the top of their namespace\n3. Split into response blocks (component schemas) vs request blocks (synthesised op types)\n4. Add `model.` prefix to response type references inside request declarations\n5. Wrap in `declare namespace model { … }` / `declare namespace model.req { … }`\n6. Append hand-written extends interfaces for ref-alias ops:\n   - pure ref body → `interface X extends model.Y {}`\n   - ref body + params → `interface X extends model.Y { param1: T; param2?: T }`\n7. Write `paths.d.ts` with `Paths` union and `PathRefs` labeled-tuple interface\n","readmeFilename":"README.md"}