{"id":18483184,"url":"https://github.com/swimlane/qswag","last_synced_at":"2025-04-08T18:32:23.807Z","repository":{"id":45539360,"uuid":"60097131","full_name":"swimlane/qswag","owner":"swimlane","description":"Fast \u0026 Light Swagger generator for .NET Core","archived":false,"fork":false,"pushed_at":"2022-09-27T14:40:45.000Z","size":325,"stargazers_count":28,"open_issues_count":21,"forks_count":6,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-03-19T22:02:42.860Z","etag":null,"topics":["csharp","dotnet","dotnet-core"],"latest_commit_sha":null,"homepage":"https://swimlane.gitbooks.io/qswag/content/","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/swimlane.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":"CODEOWNERS","security":null,"support":null}},"created_at":"2016-05-31T14:35:03.000Z","updated_at":"2023-03-09T21:29:29.000Z","dependencies_parsed_at":"2023-01-18T18:15:44.869Z","dependency_job_id":null,"html_url":"https://github.com/swimlane/qswag","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swimlane%2Fqswag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swimlane%2Fqswag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swimlane%2Fqswag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swimlane%2Fqswag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swimlane","download_url":"https://codeload.github.com/swimlane/qswag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247902435,"owners_count":21015447,"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":["csharp","dotnet","dotnet-core"],"created_at":"2024-11-06T12:34:45.469Z","updated_at":"2025-04-08T18:32:18.798Z","avatar_url":"https://github.com/swimlane.png","language":"C#","funding_links":[],"categories":["dotnet","csharp"],"sub_categories":[],"readme":"# qswag\n\nFast \u0026 Light Swagger generator for .NET Core. For more information, checkout the [documentation](https://swimlane.gitbooks.io/qswag/content/)\n\n## Example\n\n```csharp\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Net.Http;\nusing System.Reflection;\nusing System.Text;\nusing Microsoft.AspNetCore.Authorization;\nusing Microsoft.AspNetCore.Mvc;\nusing Newtonsoft.Json;\nusing QSwagGenerator;\nusing QSwagSchema;\n\nnamespace Controllers\n{\n    /// \u003csummary\u003e\n    /// Swagger spec controller.\n    /// \u003c/summary\u003e\n    /// \u003cseealso cref=\"Microsoft.AspNetCore.Mvc.Controller\" /\u003e\n    public class SwaggerController : Controller\n    {\n        private readonly List\u003cType\u003e _types;\n\n        /// \u003csummary\u003e\n        /// Initializes a new instance of the \u003csee cref=\"SwaggerController\"/\u003e class.\n        /// \u003c/summary\u003e\n        public SwaggerController()\n        {\n            _types = new List\u003cType\u003e\n            {\n                typeof(GroupsController),\n                typeof(SettingsController)\n\n            };\n        }\n        /// \u003csummary\u003e\n        /// Gets the swagger.\n        /// \u003c/summary\u003e\n        /// \u003creturns\u003eSwagger specification Json\n        /// \u003c/returns\u003e\n        [HttpGet(\"/swagger\")]\n        public ActionResult GetSwagger(params string[] type)\n        {\n            var types = type == null || type.Length \u003c= 0 ? _types : type.Select(GetTypeFromString);\n            var httpRequest = HttpContext?.Request;\n            \n            var generatorSettings = new GeneratorSettings(httpRequest)\n            {\n                DefaultUrlTemplate = \"/[controller]/{id?}\",\n                IgnoreObsolete = true,\n                Info = new Info() { Title = \"Swimlane API\", Version = \"3.0\" },\n                XmlDocPath = Path.ChangeExtension(Assembly.GetEntryAssembly().Location, \"xml\"),\n                SecurityDefinitions = new Dictionary\u003cstring, SecurityDefinition\u003e()\n                {\n                    {\n                        \"jwt_token\",\n                        new SecurityDefinition(\"Authorization\", SecuritySchemeType.ApiKey) {In = Location.Header}\n                    }\n                },\n                JsonSchemaLicense = \"YourJsonSchemaLicense\"\n            };\n            \n            generatorSettings.Security.Add(new SecurityRequirement(\"jwt_token\"));\n            var generateForControllers = WebApiToSwagger.GenerateForControllers(types, generatorSettings, nameof(GetSwagger));\n            \n            return new FileContentResult(Encoding.UTF8.GetBytes(generateForControllers), \"application/json\");\n        }\n\n        private Type GetTypeFromString(string type)\n        {\n            var typeFromString = Type.GetType(type);\n            if (typeFromString != null)\n                return typeFromString;\n            if (!type.Contains(\".\"))\n                return GetTypeFromString(string.Join(\".\", GetType().Namespace, type));\n            if (!type.EndsWith(\"controller\", StringComparison.CurrentCultureIgnoreCase))\n                return GetTypeFromString(string.Concat(type, \"Controller\"));\n            return null;\n        }\n    }\n}\n```\n\n## Building Locally\nBefore running tests locally you must set an an environment variable called `Newtonsoft` that contains the your Newtonsoft JSONSchema key.  Tests will not execute successfully without this key.\n\n## Build Job Details\nBefore merging to master the semver version attrbutes (major, minor, or patch) must be updated to reflect the type of change made.  The publish to NuGet upon merging to master will fail if the version is not updated.\n\n### Stages\n[Dotnet Restore] - Restore 3rd party NuGet packages for all projects\n[Dotnet Build] - Build all projects in release mode\n[Run Tests] - Run all tests\n[Publish] - Publishes QSwagGenerator and QSwagSchema to NuGet if a master branch build\n\n## Credits\n`qswag` is a [Swimlane](http://swimlane.com) open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswimlane%2Fqswag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswimlane%2Fqswag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswimlane%2Fqswag/lists"}