{"id":15091536,"url":"https://github.com/koshevy/oapi3codegen","last_synced_at":"2025-10-06T11:30:32.295Z","repository":{"id":57103030,"uuid":"131764821","full_name":"koshevy/oapi3codegen","owner":"koshevy","description":"Moved here — https://github.com/koshevy/codegena","archived":true,"fork":false,"pushed_at":"2019-11-23T07:35:15.000Z","size":1087,"stargazers_count":7,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-03T22:59:59.688Z","etag":null,"topics":["codegen","codegeneration","openapi","openapi3","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koshevy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-01T21:25:54.000Z","updated_at":"2023-01-28T14:51:04.000Z","dependencies_parsed_at":"2022-08-20T23:21:01.139Z","dependency_job_id":null,"html_url":"https://github.com/koshevy/oapi3codegen","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/koshevy/oapi3codegen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koshevy%2Foapi3codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koshevy%2Foapi3codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koshevy%2Foapi3codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koshevy%2Foapi3codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koshevy","download_url":"https://codeload.github.com/koshevy/oapi3codegen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koshevy%2Foapi3codegen/sbom","scorecard":{"id":568006,"data":{"date":"2025-08-11","repo":{"name":"github.com/koshevy/oapi3codegen","commit":"afff15ad03581fe9627f67b6134c71643bf4fac9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 22 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-qgfr-5hqp-vrw9","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T15:30:35.690Z","repository_id":57103030,"created_at":"2025-08-20T15:30:35.690Z","updated_at":"2025-08-20T15:30:35.690Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278601785,"owners_count":26013941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codegen","codegeneration","openapi","openapi3","typescript"],"created_at":"2024-09-25T10:41:42.010Z","updated_at":"2025-10-06T11:30:31.975Z","avatar_url":"https://github.com/koshevy.png","language":"TypeScript","readme":"# Code generation from OpenAPI 3 to TypeScript\n\nLightweight and simple. Can be used for *browser's* and for Node.js ecosystems.\nNow supports converting from **OpenAPI 3** to **TypeScript** types (OpenAPI 2 and below are not supported).\n\n\u003cdetails\u003e\n\u003csummary\u003eFor example, creates constructions such as (click to expand):\u003c/summary\u003e\n\n```typescript\n/**\n * Typical 401 response\n */\nexport interface HttpErrorUnauthorized {\n  /**\n   * Error message\n   */\n  message: string;\n\n  /**\n   * Data appropriate to\n   * [WWW-Authenticate](https://tools.ietf.org/html/rfc7235#section-3.1).\n   */\n  wwwAuthenticate?: {\n    /**\n     * Prompt to authenticate\n     */\n    title: string;\n\n    /**\n     * Kind of authorization user has to use\n     */\n    type: string;\n\n    /**\n     * Type of authority (\"barrier\" or etc.)\n     */\n    realm: string;\n  };\n}\n\nexport interface GetParametersMeta_response401\n  extends HttpErrorUnauthorized {\n\n  /**\n   * Error message\n   */\n  message: string;\n\n  /**\n   * Data appropriate to\n   * [WWW-Authenticate](https://tools.ietf.org/html/rfc7235#section-3.1).\n   */\n  wwwAuthenticate?: {\n    /**\n     * Prompt to authenticate\n     */\n    title: string;\n\n    /**\n     * Kind of authorization user has to use\n     */\n    type: string;\n\n    /**\n     * Type of authority (\"barrier\" or etc.)\n     */\n    realm: string;\n  };\n}\n\n/**\n * Kind of request error: syntax or semantic. Syntax error means the\n * application logic error, semantics — error of data, that contragent\n * inputs.\n */\nexport enum HttpErrorBadRequestTypeEnum {\n  Syntax = \"syntax\",\n  Semantic = \"semantic\"\n}\n\n/**\n * Typical response one Bad Request Error (400)\n */\nexport interface HttpErrorBadRequest {\n  /**\n   * Common error message\n   */\n  message: string;\n\n  /**\n   * Kind of request error: syntax or semantic. Syntax error means the\n   * application logic error, semantics — error of data, that contragent\n   * inputs.\n   */\n  type?: HttpErrorBadRequestTypeEnum;\n\n  /**\n   * Explained description of error\n   */\n  description?: string;\n\n  /**\n   * Additional list of errors with JSON-pointers\n   */\n  errors?: Array\u003c{\n    originalMessage: string;\n\n    message?: string;\n\n    jsonPointer: string;\n  }\u003e;\n}\n\n/**\n * ## MetaDataView\n * MetaData helps decide what the method has to use to\n * interpret and render parameter or category of parameters.\n */\nexport type GetParametersMeta_response200 = Array\u003cCategory | Parameter\u003e;\n\n```\n\u003c/details\u003e\n\n-----\n\n\u003e #### 🚦 Status of project\n\u003e - **Stabilization:** ready to use in non-production projects (see Road Map).\n\u003e - **Not supported YML (only JSON)**. *Will be supported soon. Now, you can use something like [js-yaml](https://www.npmjs.com/package/js-yaml)*\n\u003e - ***🐞 UPDATE:*** Fixed problem with infinity loop in recursive types!\n\u003e\n\u003e Please, if it possible: send me your schemas that not converts properly.\n\n### Online demo\n\nWork in progress! Now, see how to use.\n\n### Road map\n\nWork is just started, and current functionality (creating TypeScript types) —\nIt's just a first part of the supposed functionality.\nWith time, it's supposed, possibilities of this plugin will be extended by:\n\n- *Make project well documented [in progress]*\n- *YAML support [in progress]*\n- *Stabilization [in progress]*\n- *Playground site [in progress]*\n- Plugins support\n- Generation classes (now creates only interfaces) with internal validation [ *concept description is coming soon* ]\n- Generation API Classes\n    - Solutions for AngularX based on *Assured requests idea* with internal validation [ *concept description is coming soon* ]\n    - *May be, something else...*\n- **DDD-tools** (Start kit for OpenAPI3-projects):\n    - Bundler for complex files structure. Need fo organization complex API-libraries.\n    - [Dredd](https://www.npmjs.com/package/dredd)\n    - Most populars doc-generators (at least, [Redoc](https://www.npmjs.com/package/redoc) and [SwaggerUI](https://www.npmjs.com/package/swagger-ui))\n    - Convention for working with DDD OpenAPI3\n- **Other languages** (is there are need for it?): Kotlin, Java, PHP, \n\n### Ideology\n\n- **Data format loyalty:** it's should be as useful as it possible regardless validity of source data.\n- **Integration**: solution should be able to be integrated to any system (at least, based on NPM). It's mean, should have CLI and API.\n\n### Why not swagger-codegen?\n\n- Uses NPM instead Java (install via npm and easy-integratable)\n- Lightweight ([swagger-codegen](https://github.com/swagger-api/swagger-codegen) solution — it's about a 14mb for ready JAR)\n- Supports OpenAPI3\n- Above all, intended for TypeScript \n\n## Install\n\n##### 1. Install TypeScript\n\n```sh\nnpm install typescript@latest -g\n``` \n\n##### 2. Install oapi3codegen global (for CLI using)\n\n```sh\nnpm install oapi3codegen -g\n``` \n\n##### 3. Install oapi3codegen for local project\n\n```sh\nnpm install oapi3codegen --save\n``` \n\n## Using via CLI\n\n```sh\noapi3codegen --srcPath /PATH/TO/SRC/open-api-file.json --destPath /PATH/TO/DEST --separatedFiles true\n```\n\n#### CLI arguments\n\n| CLI Argument       | Description                                                                   |\n|--------------------|-------------------------------------------------------------------------------|\n| **srcPath**        | Path of url of JSON file with OpenAPI3 specification                          |\n| **destPath**       | Path for destination directory                                                |\n| **separatedFiles** | Whether should converted types be saved in separated files, or in single file |\n\nAlso, you can set some of options for convertor's [configuration](https://github.com/koshevy/oapi3codegen/blob/master/core/config.ts#L99)\nconfig via CLI:\n\n| Option                          | Description                                                                   |\n|---------------------------------|-------------------------------------------------------------------------------|\n| **defaultContentType**          | Default content-type contains no prefixes/suffixes in type names.             |\n| **implicitTypesRefReplacement** | Mode when models that refer to any models via `$ref` are replacing implicitly even if firsts have names |\n\n## Using via API (TypeScript)\n\nYou can convert whole OpenAPI3-specification:\n\n```typescript\nimport { Convertor } from 'oapi3codegen';\n\nconst convertor: Convertor = new Convertor();\n\n/**\n * Base models of specification:\n *  - Requests bodies models\n *  - Requests params sets models\n *  - Responses models\n *\n * Converting starts from entry points and extracts\n * referred types and dependencies. It s why we need\n * to get \"entry points\". \n */\nconst entryPoints = convertor.getOAPI3EntryPoints(context);\n\n/**\n * Rendering each type: every entry point and each of\n * theirs related types.\n */\nConvertor.renderRecursive(\n    entryPoints,\n    (descriptor: DataTypeDescriptor, text) =\u003e {\n        // Here your code: you get text and type descriptor.\n        // You can see how oapi3codegen's CLI uses this calback here:\n        // https://github.com/koshevy/oapi3codegen/blob/master/cli.ts#L73\n    }\n);\n```\n\nAnd also, you can convert stand-alone JSON-schema into type descriptor,\nthat could be rendered:\n\n```typescript\nimport { Convertor } from 'oapi3codegen';\n// you need prettier to beautify result of rendering\nimport * as prettier from 'prettier';\n// provides `_.each(...)` for our example\nimport * as _ from 'lodash';\n\nconst convertor: Convertor = new Convertor();\n\nconst anotherJsonSchemaObject = {\n    \"title\": \"Person\",\n    \"description\": \"Information about person you have to register in your system.\",\n    \"type\": \"object\",\n    \"properties\": {\n        \"firstName\": {\n            \"type\": \"string\"\n        },\n        \"lastName\": {\n            \"type\": \"string\"\n        },\n        \"age\": {\n            \"description\": \"Age in years\",\n            \"type\": \"integer\",\n            \"minimum\": 0\n        }\n    },\n    \"required\": [\"firstName\", \"lastName\"]\n};\n\nconst convertResult = convertor.convert(\n    anotherJsonSchemaObject,\n    {},\n    'AnotherType'\n);\n\n_.each(convertResult, typeDescriptor =\u003e {\n    const typeCode = prettier.format(\n        typeDescriptor.render([]),\n        {parser: 'typescript'}\n    );\n\n    console.log(typeCode);\n});\n\n```\n\nAnd this code will print result:\n\n```typescript\n/**\n * ## Person\n * Information about person you have to register in your system.\n */\nexport interface AnotherType {\n  firstName: string;\n\n  lastName: string;\n\n  /**\n   * Age in years\n   */\n  age?: number;\n}\n```\n\n## API (TypeScript)\n\nComing soon...\n\n## How to extend?\n\nComing soon...","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoshevy%2Foapi3codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoshevy%2Foapi3codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoshevy%2Foapi3codegen/lists"}