{"id":16171855,"url":"https://github.com/fmvilas/swagger-node-codegen","last_synced_at":"2025-04-05T03:10:17.149Z","repository":{"id":46032058,"uuid":"46659429","full_name":"fmvilas/swagger-node-codegen","owner":"fmvilas","description":"An OpenAPI 3.x/Swagger 2 code generator for Node.js","archived":false,"fork":false,"pushed_at":"2021-11-18T19:24:38.000Z","size":261,"stargazers_count":200,"open_issues_count":10,"forks_count":55,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-11T03:44:18.209Z","etag":null,"topics":["codegen","nodejs","openapi","openapi3","swagger"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fmvilas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-22T12:22:22.000Z","updated_at":"2024-06-26T12:27:40.000Z","dependencies_parsed_at":"2022-09-02T19:32:00.289Z","dependency_job_id":null,"html_url":"https://github.com/fmvilas/swagger-node-codegen","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmvilas%2Fswagger-node-codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmvilas%2Fswagger-node-codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmvilas%2Fswagger-node-codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmvilas%2Fswagger-node-codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fmvilas","download_url":"https://codeload.github.com/fmvilas/swagger-node-codegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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","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","nodejs","openapi","openapi3","swagger"],"created_at":"2024-10-10T03:44:14.663Z","updated_at":"2025-04-05T03:10:17.131Z","avatar_url":"https://github.com/fmvilas.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003ch1\u003eTHIS PACKAGE IS NOT MAINTAINED ANYMORE. IF YOU WANT TO MAINTAIN IT DROP ME A LINE AT fran.mendez[at]hey.com.\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"logo.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eOpenAPI Node.js\u003cbr\u003eCode Generator\u003c/strong\u003e\n\u003c/p\u003e\n\u003cbr\u003e\u003cbr\u003e\nUse your API OpenAPI 3.x/Swagger 2 definition to generate Node.js ES7-compliant code for your API.\n\nThe generated code features:\n\n* ES7\n* ESLint\n* YAML config file\n* Express\n* No transpiling\n\n## Install\n\nTo use it from the CLI:\n\n```bash\nnpm install -g swagger-node-codegen\n```\n\nTo use it as a module in your project:\n\n```bash\nnpm install --save swagger-node-codegen\n```\n\n## Requirements\n\n* Node.js v7.6+\n\n## Usage\n\n### From the command-line interface (CLI)\n\n```bash\n  Usage: snc [options] \u003cswaggerFile\u003e\n\n\n  Options:\n\n    -V, --version                  output the version number\n    -o, --output \u003coutputDir\u003e       directory where to put the generated files (defaults to current directory)\n    -t, --templates \u003ctemplateDir\u003e  directory where templates are located (defaults to internal nodejs templates)\n    -h, --help                     output usage information\n```\n\n#### Examples\n\nThe shortest possible syntax:\n```bash\nsnc swagger.yaml\n```\n\nSpecify where to put the generated code:\n```bash\nsnc swagger.yaml -o ./my-api\n```\n\n### As a module in your project\n\n```js\nconst path = require('path');\nconst codegen = require('swagger-node-codegen');\nconst swagger = require('./swagger.json');\n\ncodegen.generate({\n  swagger,\n  target_dir: path.resolve(__dirname, './my-api')\n}).then(() =\u003e {\n  console.log('Done!');\n}).catch(err =\u003e {\n  console.error(`Something went wrong: ${err.message}`);\n});\n```\n\nThe `swagger` parameter can be either JSON or a path pointing to a JSON or YAML file.\n\n```js\nconst path = require('path');\nconst codegen = require('swagger-node-codegen');\n\ncodegen.generate({\n  swagger: path.resolve(__dirname, './swagger.yml'),\n  target_dir: path.resolve(__dirname, './my-api')\n}).then(() =\u003e {\n  console.log('Done!');\n}).catch(err =\u003e {\n  console.error(`Something went wrong: ${err.message}`);\n});\n```\n#### Using async/await\n\nThe function `codegen.generate` returns a Promise, so it means you can use async/await:\n\n```js\nconst path = require('path');\nconst codegen = require('swagger-node-codegen');\n\ntry {\n  await codegen.generate({\n    swagger: path.resolve(__dirname, './swagger.yml'),\n    target_dir: path.resolve(__dirname, './my-api')\n  });\n  console.log('Done!');\n} catch (err) {\n  console.error(`Something went wrong: ${err.message}`);\n}\n```\n\n## API Documentation\n\n### Modules\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#module_codegen\"\u003ecodegen\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eThis module generates a code skeleton for an API using OpenAPI/Swagger.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#codegen.module_generate\"\u003egenerate\u003c/a\u003e ⇒ \u003ccode\u003ePromise\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGenerates a code skeleton for an API given an OpenAPI/Swagger file.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"module_codegen\"\u003e\u003c/a\u003e\n\n### codegen\nThis module generates a code skeleton for an API using OpenAPI/Swagger.\n\n\u003ca name=\"codegen.module_generate\"\u003e\u003c/a\u003e\n\n#### generate ⇒ \u003ccode\u003ePromise\u003c/code\u003e\nGenerates a code skeleton for an API given an OpenAPI/Swagger file.\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| config | \u003ccode\u003eObject\u003c/code\u003e | Configuration options |\n| config.swagger | \u003ccode\u003eObject\u003c/code\u003e \\| \u003ccode\u003eString\u003c/code\u003e | OpenAPI/Swagger JSON or a string pointing to an OpenAPI/Swagger file. |\n| config.target_dir | \u003ccode\u003eString\u003c/code\u003e | Path to the directory where the files will be generated. |\n| config.templates| \u003ccode\u003eString\u003c/code\u003e | Path to the directory where custom templates are (optional). |\n\n\n## Templates\nYou can create your own [templates](./templates/README.md).\n\n## Authors\n\n* Fran Méndez ([@fmvilas](http://twitter.com/fmvilas))\n* Richard Klose ([@richardklose](http://github.com/richardklose))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmvilas%2Fswagger-node-codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffmvilas%2Fswagger-node-codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmvilas%2Fswagger-node-codegen/lists"}