{"id":15676916,"url":"https://github.com/smacker/go-swagger-gen","last_synced_at":"2025-09-05T11:09:33.165Z","repository":{"id":57500711,"uuid":"81915713","full_name":"smacker/go-swagger-gen","owner":"smacker","description":"A tool to parse Golang source files and generate Swagger json.","archived":false,"fork":false,"pushed_at":"2021-11-12T16:18:35.000Z","size":107,"stargazers_count":13,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-12T04:10:08.307Z","etag":null,"topics":["golang","swagger","swagger-generator"],"latest_commit_sha":null,"homepage":"","language":"Go","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/smacker.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":"2017-02-14T07:03:16.000Z","updated_at":"2024-04-02T17:50:38.000Z","dependencies_parsed_at":"2022-08-30T20:10:23.847Z","dependency_job_id":null,"html_url":"https://github.com/smacker/go-swagger-gen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/smacker/go-swagger-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fgo-swagger-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fgo-swagger-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fgo-swagger-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fgo-swagger-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smacker","download_url":"https://codeload.github.com/smacker/go-swagger-gen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fgo-swagger-gen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273747788,"owners_count":25160652,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"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":["golang","swagger","swagger-generator"],"created_at":"2024-10-03T16:07:10.318Z","updated_at":"2025-09-05T11:09:33.140Z","avatar_url":"https://github.com/smacker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Go Swagger Generator\n==================\n\nGo Swagger Generator is a tool to parse Golang source files and generate Swagger json.\n\nTool is based on [go-swagger](https://github.com/go-swagger/go-swagger)\nand supports everything that go-swagger supports, but allows to define responses and parameters as yaml.\n\nWhy?\n----\n\nGo-swagger expects separate structure for every response, but in my case we generate it dynamically in controller.\n\nExample\n-------\n\n```go\n// swagger:route PUT /packages/{id} Package packagePut\n//\n// Update package\n//\n// Parameters:\n// id      string     in:path required \"Package ID\"\n// content PutPackage in:body required \"Update package params\"\n// | - name: type\n// |   in: query\n// |   description: Example parameter defined as yaml\n// |   required: true\n// |   type: string\n// |   enum:\n// |     - value1\n// |     - value2\n//\n// Responses:\n// 200: \"OK\"\n// | schema:\n// |   properties:\n// |     data:\n// |       $ref: \"#/definitions/PackageGet\"\n// |     meta:\n// |       $ref: \"#/definitions/Meta\"\n// 404: \"Package not found\"\n// | schema:\n// |   $ref: \"#/definitions/ErrorResponse\"\n// 422: \"422 Unprocessable Entity\"\n// | schema:\n// |   $ref: \"#/definitions/ErrorResponse\"\nfunc PackagePut() http.HandlerFunc {\n    ...\n}\n```\n\nUsage\n-----\n\n`go-swagger-gen spec -m -i third_party_swagger.json -b project/cmd/http -o swagger.json --compact`\n\n```\nUsage:\n  go-swagger-gen [OPTIONS] spec [spec-OPTIONS]\n\ngenerate spec file from go code\n\nHelp Options:\n  -h, --help             Show this help message\n\n[spec command options]\n      -b, --base-path=   the base path to use (default: .)\n      -m, --scan-models  includes models that were annotated with 'swagger:model'\n          --compact      when present, doesn't prettify the the json\n      -o, --output=      the file to write to\n      -i, --input=       the file to use as input\n```\n\nDocumentation\n-------------\n\nPlease refer to [go-swagger documentation](https://goswagger.io/generate/spec.html), swagger.json section.\n\nWhat is new compare to go-swagger\n-------------\n\n### Parameters shortcuts\n\nAllows to define route params in short form:\n\n```\n// swagger:route ...\n//\n// Parameters:\n// \u003cname\u003e  \u003ctype\u003e  in:\u003cplace\u003e  \u003cis-required\u003e \"\u003cdescription\u003e\"\n```\n\nWhere:\n- `name` - parameter name\n- `type` - any go type or struct with `swagger:model` annotation\n- `place` - path/query/header/body/formData\n- `is-required` - true/false or required (works as true)\n\n### Parameters yaml\n\n```\n// swagger:route ...\n//\n// Parameters:\n// | valid swagger parameters yaml as array\n```\n\nJust put here normal swagger yaml, but prepend it with `| ` symbol.\n\n### Response yaml\n\n```\n// swagger:route ...\n//\n// Responses:\n// \u003ccode\u003e: \"\u003cdescription\u003e\"\n// | valid swagger response yaml\n```\n\nWhere:\n- `code` - integer response code\n- `description` - response description\n\nJust put here normal swagger yaml, but prepend it with `| ` symbol.\n\n### Define string format of struct field in comment\n\n```go\ntype MyModelResponseDTO struct {\n    // format: date-time\n    CreatedAt string `json:\"created_at\"`\n}\n```\n\n### time.Time fields are string.date-time by default\n\n```go\ntype MyModelInputDTO struct {\n    CreatedAt time.Time `json:\"created_at\"`\n}\n```\n\n### Get required fields from valid/validation struct tag\n\n```go\ntype MyModelInputDTO struct {\n    //don't need to add \"required\" comment\n    CreatedAt time.Time `json:\"created_at\" valid:\"required\"`\n}\n```\n\n### Skip private comments\n\n```go\ntype MyModelInputDTO struct {\n    //technical comment, shouldn't appear as description in swagger\n    // but this comment is used as description\n    CreatedAt time.Time `json:\"created_at\" valid:\"required\"`\n}\n```\n\n### Better alias support\n\n```go\ntype Int64 int64\n\ntype MyModel struct {\n    // min: 10\n    IntField Int64 `json:\"intField\"`\n}\n```\n\nAliases in swagger.json present as native types. Therefore all validation comments work as expected for them.\n\n(similar fix was merged to go-swagger https://github.com/go-swagger/go-swagger/pull/1087, but works slightly different)\n\n### x-go-name extension was removed\n\nI don't want to expose internal name in swagger\n\n### Don't put unused definitions in result swagger.json\n\nScanner creates swagger definitions for embedded structures too, but often we don't need them.\n\nConsider example:\n\n```go\ntype BaseModel struct {\n    ...\n}\n\n// swagger:model\ntype MyModel struct {\n    BaseModel\n    ...\n}\n\n// we use only \"#/definitions/MyModel\" somewhere\n// but BaseModel definition will also appear in swagger json\n```\n\nTherefore `go-swagger-gen` analyzes final json and removes unused definitions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fgo-swagger-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmacker%2Fgo-swagger-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fgo-swagger-gen/lists"}