{"id":14986762,"url":"https://github.com/multivacplatform/swagger-node","last_synced_at":"2025-04-11T23:00:24.957Z","repository":{"id":65507642,"uuid":"178666201","full_name":"multivacplatform/swagger-node","owner":"multivacplatform","description":"Swagger module for node.js","archived":false,"fork":false,"pushed_at":"2019-10-17T09:55:25.000Z","size":2645,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T18:54:02.371Z","etag":null,"topics":["javascript","openapi-specification","rest","rest-api","swagger","swagger-api","swagger-node"],"latest_commit_sha":null,"homepage":"http://swagger.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multivacplatform.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":"2019-03-31T09:15:35.000Z","updated_at":"2019-10-17T09:55:27.000Z","dependencies_parsed_at":"2023-01-26T15:45:34.698Z","dependency_job_id":null,"html_url":"https://github.com/multivacplatform/swagger-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multivacplatform%2Fswagger-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multivacplatform%2Fswagger-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multivacplatform%2Fswagger-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multivacplatform%2Fswagger-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multivacplatform","download_url":"https://codeload.github.com/multivacplatform/swagger-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492875,"owners_count":21113162,"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":["javascript","openapi-specification","rest","rest-api","swagger","swagger-api","swagger-node"],"created_at":"2024-09-24T14:13:29.165Z","updated_at":"2025-04-11T23:00:24.927Z","avatar_url":"https://github.com/multivacplatform.png","language":"JavaScript","readme":"# swagger-node\n\n[![Build Status](https://travis-ci.org/multivacplatform/swagger-node.svg?branch=master)](https://travis-ci.org/multivacplatform/swagger-node)\n[![NPM version](https://badge.fury.io/js/swagger-node.svg)](http://badge.fury.io/js/swagger-node)\n[![Dependency Status](https://david-dm.org/multivacplatform/swagger-node/status.svg)](https://david-dm.org/multivacplatform/swagger-node)\n[![devDependency Status](https://david-dm.org/multivacplatform/swagger-node/dev-status.svg)](https://david-dm.org/multivacplatform/swagger-node#info=devDependencies)\n\nThe `swagger` module provides tools for designing and building Swagger-compliant APIs entirely in Node.js. It integrates with popular Node.js servers, including Express, Hapi, Restify, and Sails, as well as any Connect-based middleware. With `swagger`, you can specify, build, and test your API from the very beginning, on your laptop. It allows you to change and iterate your design without rewriting the logic of your implementation.\n\n![alt text](./docs/images/overview2.png)\n\nRemember, one great thing about this approach is that all of the Swagger validation logic is handled for you, and all of the routing logic is managed through the Swagger configuration. You don't have to code (or recode!) any of that stuff yourself.\n\n## Your swagger API in five steps\n\n### 1. Install the swagger module\n\nInstall using npm. For complete instructions, see the [install](./docs/install.md) page.\n\n```bash\nnpm install -g swagger-node\n```\n\n### 2. Create a new swagger project\n\nUse the [CLI](./docs/cli.md) to create and manage projects. Learn more on the [quick start](./docs/quick-start.md) page.\n\n```bash\nswagger project create hello-world\n```\n\n### 3. Design your API in the Swagger Editor\n\nThe interactive, browser-based [Swagger Editor](http://editor.swagger.io/) is built in. It provides Swagger 2.0 validation and endpoint routing, generates docs on the fly, and consumes easy-to-read YAML.\n\n```bash\nswagger project edit\n```\n\n![screenshot of project editor](./docs/images/project-editor.png)\n\n### 4. Write controller code in Node.js\n\nCode your API's business logic in Node.js.\n\n```js\nfunction hello(req, res) {\n    var name = req.swagger.params.name.value || 'stranger';\n    var hello = util.format('Hello, %s!', name);\n    res.json({ \"message\": hello });\n}\n```\n\nIf you look at the Swagger file in the editor (shown in step 3 above), the `x-swagger-router-controller` element (line 17 in the editor screenshot) specifies the name of the controller file associated with the `/hello` path. For example:\n\n```yaml\n    paths:\n        /hello:\n            x-swagger-router-controller: hello_world\n```\n\nController source code is always placed in `./api/controllers`. So, the controller source file for this project is `./api/controllers/hello_world.js`.\n\nThe `operationId` element specifies which controller function to call. In this case (line 19), it is a function called `hello`. Learn [more](./docs/controllers.md).\n\n### 5. Run the server\n\nRun the project server.\n\n```bash\nswagger project start\n```\n\n## Now, call the API\n\nIt just works!\n\n```bash\n$ curl http://127.0.0.1:10010/hello?name=Scott\n{ \"message\": \"Hello, Scott!\" }\n```\n\n## \u003ca name=\"installation\"\u003e\u003c/a\u003eInstalling the swagger module\n\nSee the [Installing swagger](./docs/install.md) for details.\n\n## \u003ca name=\"using\"\u003e\u003c/a\u003eUsing the swagger module\n\nGo to the [swagger module doc page](./docs/README.md). It includes all the information you need to get started.\n\n## \u003ca name=\"about\"\u003e\u003c/a\u003eAbout this project\n\nThis initiative grew out of Apigee-127, an API design-first development framework using Swagger.\nApigee donated the code to create the swagger-node project in 2015.\n\n \u003eCopyright 2016 Apigee Corporation\n \u003eLicensed under the Apache License, Version 2.0 (the \"License\");\n\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n \u003ehttp://www.apache.org/licenses/LICENSE-2.0\n \u003eUnless required by applicable law or agreed to in writing, software\n\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n---\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultivacplatform%2Fswagger-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultivacplatform%2Fswagger-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultivacplatform%2Fswagger-node/lists"}