{"id":26428951,"url":"https://github.com/brokenprogrammer/mswg-gen","last_synced_at":"2025-09-10T18:43:00.187Z","repository":{"id":40581750,"uuid":"507563615","full_name":"brokenprogrammer/mswg-gen","owner":"brokenprogrammer","description":"Custom OpenAPI generator that is used to generate swagger documentation using comments.","archived":false,"fork":false,"pushed_at":"2022-06-26T19:51:28.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T04:52:38.362Z","etag":null,"topics":["api","generator","openapi","openapi-generator","openapi3"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brokenprogrammer.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":"2022-06-26T12:07:17.000Z","updated_at":"2022-06-26T12:39:07.000Z","dependencies_parsed_at":"2022-08-27T02:48:46.292Z","dependency_job_id":null,"html_url":"https://github.com/brokenprogrammer/mswg-gen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/brokenprogrammer/mswg-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2Fmswg-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2Fmswg-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2Fmswg-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2Fmswg-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brokenprogrammer","download_url":"https://codeload.github.com/brokenprogrammer/mswg-gen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brokenprogrammer%2Fmswg-gen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259395459,"owners_count":22850833,"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":["api","generator","openapi","openapi-generator","openapi3"],"created_at":"2025-03-18T04:52:40.686Z","updated_at":"2025-06-12T04:14:27.010Z","avatar_url":"https://github.com/brokenprogrammer.png","language":"C","readme":"# mswg-gen\nCustom OpenAPI generator that is used to generate swagger documentation using comments.\n\nThe project currently has support for C \u0026 Go language but can technically support any programming language \nthat makes use of C style comments. Some parsing has to be added however.\n\nThe goal of this project is to have a fast swagger generator that is excluded from the project that can easily be integrated\ninto any build pipeline.\n\n## Usage\n\nFirst you need to create a config.ini file within your project directory. An example configuration looks like the following:\n\n```ini\n; This is a comment\n[mswgen]\ntitle = Sample\n# This is also a comment\ndescription = This is a sample application\ntermsofservice = https://google.se\n\n[mswgen.contact]\nname = Support\nurl = https://google.se\nemail = support@google.se\n\n[mswgen.license]\nname = MIT\nurl = https://google.se\n\n[mswgen.version]\nversion= v1\n```\n\nExplanation for the different configuration settings are explained in the following table.\n| Configuration | Description   | Example       |\n| ------------- | ------------- | ------------- |\n| title  | The title of your application. This will be displayed on your swagger page. | My Appllication |\n| description  | Description of your application. Will be displayed on your swagger page.  | This is a sample application |\n| termsofservice  | A link to the terms of service for your API..  | https://example.com |\n| contact.name  | Display name for your contact.  | Support |\n| contact.url  | Contact URL..  | https://example.com |\n| contact.email  | Contact email.  | support@example.com |\n| license.name  | Name of the license for your API.  | MIT |\n| license.url  | URL to license of your API.  | https://example.com/license |\n| version.version | Version of your API. | v1 |\n\nAfter you have set up your configuration file you can build the application by entering the `src` directory and run `make`.\n\nOnce done you should have access to the executable `mswg_gen` that you can place where you want it.\n\nFinally some modification is needed in the code of your application. mswg_gen uses two types of comment to specify two different API types routes and route types.\n\n### Routes\n\nA new route is specified by writing a comment in your code with the following format:\n```C\n// @Route(route, method, return_type)\n```\n\nAn example would be\n\n```C\n// @Route(/api/login, post, user_object)\n```\n\nSome routes do not return any json objects hence the `return_type` can also be emitteed like so:\n\n```C\n// @Route(/api/register, post)\n```\n\n### Route Types\n\nRoute types are added by annotating your structures using the `@RouteType` command.\nThis allows mswg_gen to add the type to the list of known `return_types` for routes in order to generate json within swagger.\n\nExample:\n```C\n// @RouteType\ntypedef struct {\n    u_int32_t state[5];\n    u_int64_t count;\n    u_int8_t buffer[SHA1_BLOCK_LENGTH];\n} SHA1_CTX;\n```\n\n### Integrating into your project\n\nThe output of mswg_gen can easily be output in a file like so:\n```bash\n./mswg_gen \u003e example.txt\n```\n\nThe generated output can then be used together with the static swagger site provided \nwithin this repository: \u003chttps://github.com/swagger-api/swagger-ui\u003e\n\nThis is easy to set up by downloading the latest release and using the static HTML/JS/CSS within the downloaded `/dist` folder.\n\n## Disclaimer\n\nThis application was written in a very short duration and a lot of shortcuts was taken. If you find bugs please file an issue or a pull request. \n\n# License\n\nMIT License\n\nCopyright (c) 2022 Oskar Mendel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrokenprogrammer%2Fmswg-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrokenprogrammer%2Fmswg-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrokenprogrammer%2Fmswg-gen/lists"}