{"id":41744831,"url":"https://github.com/tinh-tinh/swagger","last_synced_at":"2026-01-25T00:48:08.329Z","repository":{"id":256809551,"uuid":"856466354","full_name":"tinh-tinh/swagger","owner":"tinh-tinh","description":"📗 Swagger module for Tinh Tinh framework","archived":false,"fork":false,"pushed_at":"2025-11-17T15:36:24.000Z","size":126,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-17T17:26:38.732Z","etag":null,"topics":["framework","swagger"],"latest_commit_sha":null,"homepage":"https://tinh-tinh.github.io/docs/docs/intergrations/swagger","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/tinh-tinh.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,"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}},"created_at":"2024-09-12T16:11:19.000Z","updated_at":"2025-11-17T15:36:29.000Z","dependencies_parsed_at":"2024-09-13T06:34:10.481Z","dependency_job_id":"9da29d8d-7c42-4cd7-a856-fdc64b3b9854","html_url":"https://github.com/tinh-tinh/swagger","commit_stats":null,"previous_names":["tinh-tinh/swagger"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/tinh-tinh/swagger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fswagger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fswagger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fswagger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fswagger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinh-tinh","download_url":"https://codeload.github.com/tinh-tinh/swagger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fswagger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28740271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["framework","swagger"],"created_at":"2026-01-25T00:48:07.592Z","updated_at":"2026-01-25T00:48:08.323Z","avatar_url":"https://github.com/tinh-tinh.png","language":"Go","readme":"# Swagger Module for Tinh Tinh\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg alt=\"GitHub Release\" src=\"https://img.shields.io/github/v/release/tinh-tinh/swagger\"\u003e\n\u003cimg alt=\"GitHub License\" src=\"https://img.shields.io/github/license/tinh-tinh/swagger\"\u003e\n\u003ca href=\"https://codecov.io/gh/tinh-tinh/swagger\" \u003e \n \u003cimg src=\"https://codecov.io/gh/tinh-tinh/swagger/graph/badge.svg?token=WTLU1P7INE\"/\u003e \n \u003c/a\u003e\n\u003ca href=\"https://pkg.go.dev/github.com/tinh-tinh/swagger\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/tinh-tinh/swagger.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://avatars.githubusercontent.com/u/178628733?s=400\u0026u=2a8230486a43595a03a6f9f204e54a0046ce0cc4\u0026v=4\" width=\"200\" alt=\"Tinh Tinh Logo\"\u003e\n\u003c/div\u003e\n\n## Overview\n\nThe Swagger module for Tinh Tinh provides automatic OpenAPI 3.0 documentation and a built-in Swagger UI for your Tinh Tinh-based APIs. It introspects your controllers, DTOs, routes, and metadata to generate a standards-compliant OpenAPI spec.\n\n## Features\n\n- Generates OpenAPI 3.0 spec from your Tinh Tinh app\n- Auto-discovers routes, query/body/path parameters, responses, and security\n- Adds detailed schemas from your DTOs and validation tags\n- Supports file upload, security schemes, tags, and custom consumers\n- Ready-to-use Swagger UI, served directly from your app\n- Easily extensible and customizable via metadata\n\n## Installation\n\n```bash\ngo get -u github.com/tinh-tinh/swagger/v2\n```\n\n## Quick Start Example\n\n```go\nimport (\n    \"github.com/tinh-tinh/swagger/v2\"\n    \"github.com/tinh-tinh/tinhtinh/v2/core\"\n)\n\nserver := core.CreateFactory(AppModule)\nserver.SetGlobalPrefix(\"/api\")\n\n// Build the OpenAPI spec\nspec := swagger.NewSpecBuilder().\n    SetTitle(\"My API\").\n    SetServer(\u0026swagger.ServerObject{\n        Url: \"http://localhost:3000/api\",\n    }).\n    SetDescription(\"API documentation for my service\").\n    SetVersion(\"1.0.0\").\n    AddSecurity(\u0026swagger.SecuritySchemeObject{\n        Type:         \"http\",\n        Scheme:       \"Bearer\",\n        BearerFormat: \"JWT\",\n        Name:         \"bearerAuth\",\n    }).\n    Build()\n\n// Parse all app routes and generate spec\nspec.ParsePaths(server)\n\n// Mount Swagger UI and OpenAPI JSON\nswagger.SetUp(\"/swagger\", server, spec)\n```\n\n- Swagger UI will be available at: `http://localhost:3000/swagger`\n- OpenAPI JSON will be at: `http://localhost:3000/openapi.json`\n\n## Usage Patterns\n\n### Controller and DTO Example\n\n```go\ntype SignUpUser struct {\n    Name     string    `validate:\"isAlpha\" example:\"John\"`\n    Email    string    `validate:\"required,isEmail\" example:\"john@gmail.com\"`\n    Password string    `validate:\"required,isStrongPassword\" example:\"12345678@Tc\"`\n    Birth    time.Time `validate:\"required\" example:\"2024-12-12\"`\n    Avatar   string    `example:\"https://cdn.tinhtinh.dev/images/avatar.png\"`\n}\n\nfunc authController(module core.Module) core.Controller {\n    return module.NewController(\"Auth\").\n        Metadata(swagger.ApiTag(\"Auth\")).Registry().\n        Pipe(core.Body(SignUpUser{})).\n        Post(\"\", func(ctx core.Ctx) error {\n            payload := ctx.Body().(*SignUpUser)\n            return ctx.JSON(core.Map{\"data\": payload})\n        })\n}\n```\n\n### Add Route Metadata\n\n#### Tags\n```go\nswagger.ApiTag(\"User\")\n```\n\n#### Security\n```go\nswagger.ApiSecurity(\"bearerAuth\")\n```\n\n#### Consumers (e.g., multipart)\n```go\nswagger.ApiConsumer(\"multipart/form-data\")\n```\n\n#### File Upload\n```go\nswagger.ApiFile(swagger.FileOptions{\n    Name: \"image\",\n    Description: \"user avatar (image file)\",\n    Required: true,\n})\n```\n\nExample controller for image upload:\n```go\ntype UploadFile struct {\n    Image storage.File `example:\"image\"`\n}\n\nfunc fileController(module core.Module) core.Controller {\n    ctrl := module.NewController(\"Files\").\n        Metadata(swagger.ApiTag(\"File\")).\n        Metadata(swagger.ApiConsumer(\"multipart/form-data\")).\n        Metadata(swagger.ApiFile(swagger.FileOptions{\n            Name: \"image\",\n            Description: \"User image file\",\n            Required: true,\n        }))\n\n    ctrl.Pipe(core.Body(UploadFile{})).Post(\"/upload\", func(ctx core.Ctx) error {\n        file := ctx.Body().(*UploadFile)\n        // handle file.Image\n        return ctx.JSON(core.Map{\"url\": \"https://cdn.tinhtinh.dev/images/example-upload.png\"})\n    })\n\n    return ctrl\n}\n```\n\n#### Custom Response Schema\n```go\nswagger.ApiOkResponse(\u0026Response{\n    Title: \"Acrane\",\n    Image: \"https://cdn.tinhtinh.dev/images/sample-image.png\",\n})\n```\n\n## How It Works\n\n- Parses all controllers and their routes for HTTP methods, paths, and DTOs\n- Uses struct tags (`query`, `path`, `example`, `validate`, etc.) to generate detailed parameter and schema info\n- Automatically creates OpenAPI-compliant docs with proper reference linking\n- Renders a modern Swagger UI using CDN assets\n\n## Customize and Extend\n\n- Use your own metadata (tags, security, consumers, file options) on controllers/routes\n- Add/override OpenAPI info in the `SpecBuilder`\n- Mix multiple modules/controllers and all routes will be scanned\n\n## Contributing\n\nWe welcome contributions! Please feel free to submit a Pull Request.\n\n## Support\n\nIf you encounter any issues or need help, you can:\n- Open an issue in the GitHub repository\n- Check our documentation\n- Join our community discussions\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinh-tinh%2Fswagger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinh-tinh%2Fswagger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinh-tinh%2Fswagger/lists"}