{"id":36546280,"url":"https://github.com/tiemma/sonic-express","last_synced_at":"2026-01-12T06:04:21.637Z","repository":{"id":42685172,"uuid":"314031612","full_name":"tiemma/sonic-express","owner":"tiemma","description":"Automates generating your API docs on swagger","archived":false,"fork":false,"pushed_at":"2024-01-09T17:55:03.000Z","size":1383,"stargazers_count":109,"open_issues_count":14,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-09T03:58:16.350Z","etag":null,"topics":["api","express","swagger"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/tiemma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-11-18T19:06:17.000Z","updated_at":"2025-07-01T22:00:25.000Z","dependencies_parsed_at":"2025-09-09T03:42:16.770Z","dependency_job_id":"3fa08661-3b90-45bf-8f5b-f21ace37370f","html_url":"https://github.com/tiemma/sonic-express","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/tiemma/sonic-express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiemma%2Fsonic-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiemma%2Fsonic-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiemma%2Fsonic-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiemma%2Fsonic-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiemma","download_url":"https://codeload.github.com/tiemma/sonic-express/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiemma%2Fsonic-express/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"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":["api","express","swagger"],"created_at":"2026-01-12T06:03:00.613Z","updated_at":"2026-01-12T06:04:21.621Z","avatar_url":"https://github.com/tiemma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sonic \u003c express \u003e\n\n![image](https://raw.githubusercontent.com/Tiemma/sonic-core/master/image.png) \n\nAccelerate your swagger doc experience on Express.\n\n![CodeQL](https://github.com/Tiemma/sonic-express/workflows/CodeQL/badge.svg)\n![Node.js CI](https://github.com/Tiemma/sonic-express/workflows/Node.js%20CI/badge.svg)\n\n# What does this do?\nThis hooks into the Express `res` and `req` API and auto-documents each response for you so you never have to.\n\nImagine writing 100 APIs and having it entirely documented, that's what this helps you with.\n\n# How to use it\n\n- Install the package\n- Import the middleware\n- Pass in the options\n- Sit back and call your APIs\n\n## Install the package\nTo install the package, run\n```bash\nnpm install --save @tiemma/sonic-express\n```\n\n## Import the middleware\nThe middleware for this project is currently exposed for only Express.\n```javascript\nimport { getResponseExpress } from '@tiemma/sonic-express';\n```\n\n## Pass in the options\nThe express middleware requires three parameters\n - Top-level app instance\n - Swagger options (you can use the example [here](./examples/swagger-config.js) if you need one)\n - Path to where the generated swagger file should be saved\n```javascript\nimport { getResponseExpress } from '@tiemma/sonic-express';\nimport options from './swagger-config';\n\napp.use(getResponseExpress(app, options, './examples/swagger.json'));\n```\n\nIf you're considering adding this for other JS web frameworks, have a look at the core API [here](https://github.com/Tiemma/sonic-core) and see how to extract the required parameters for that framework.\n\n## Sit back and call your APIs\nOnce the middleware is initiated, all API calls that match the domains within `servers[*].url` in the swagger specification will be logged.\nFor example, the `servers` block in the options stated [here](./examples/swagger-config.js) has an url entry for `/api/v1`.\nSo all URLs containing `/api/v1` will be logged, `/api/v2` entries will not.\n\nTo enable for other URL prefixes, add the entry to the `servers` block and they will be automatically logged.\n\n# Why did I do this?\nI got tired of tickets to update the swagger documentation which isn't easy or also extremely fun to do.\n\nSo whilst creating a simple handler to record the requests, I started this project.\n\n# What can I do with this?\nYou can use it to avoid writing a majority of the swagger specification or none at all for your express projects.\n\n# What specifications is this project written in?\nCurrently, the core API section starting [here](https://github.com/Tiemma/sonic-core/blob/master/src/swagger-utils.js#L318) handles swagger 2 and 3 configurations quite fine.\n\nDoubt it!?, test the swagger file [here](./examples/swagger.json) on [editor.swagger.io](editor.swagger.io).\nThe spec listed above was generated using this same tool from tests [here](./test).\n\n# Best Practices \n1. Ensure you enable the middleware during tests\n- Unless you prefer overwriting parameters during development, it's best to keep the middleware working on a testing configuration so you don't mistakenly generate docs in production and slow down your API :-).\nThe handler keeps the swaggerDoc in memory and writes updates per request.\n```javascript\nif(process.env.NODE_ENV === 'testing') {\n    app.use(getResponseExpress(app, options, './examples/swagger.json'));\n}\n```\n\n2. You can still add docs for your APIs\n- The middleware will adequately handle generating the swagger docs for undocumented routes.\nBy undocumented routes, I mean routes without these fancy JSDoc comments\n```javascript\n/**\n * @swagger\n * ...inserts more docs, arrrghhhh\n */\n```\n\nDespite the ease of this, be sure to add descriptions where needed for your end users.\n```javascript\n/**\n * @swagger\n * /mouse/{id}/man:\n *   post:\n *     name: mouse\n *     summary: Create mouse\n *     description: Creates a mouse under a man's house, rhymes with the times dudes\n */\n```\n\n3. That's about it from me, the rest is with you, me, the Issues page on this repo and Stackoverflow.\n\n# Debugging\nLogs from the core API can be exposed by setting the `DEBUG` environment variable.\n```bash\nexport DEBUG=\"@tiemma/sonic-core\"\n```\n\n# I found a bug, how can I contribute?\nOpen up a PR using the ISSUE TEMPLATE [here](./.github/ISSUE_TEMPLATE/feature_request.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiemma%2Fsonic-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiemma%2Fsonic-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiemma%2Fsonic-express/lists"}