{"id":15285732,"url":"https://github.com/chenyunda218/openapi-go-generator","last_synced_at":"2026-05-07T01:03:25.466Z","repository":{"id":183622516,"uuid":"670407272","full_name":"chenyunda218/openapi-go-generator","owner":"chenyunda218","description":"openapi go gin server generator","archived":false,"fork":false,"pushed_at":"2023-11-22T03:59:24.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T21:13:31.118Z","etag":null,"topics":["api-first","apis","gin","go","openapi","webapi"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenyunda218.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}},"created_at":"2023-07-25T01:52:05.000Z","updated_at":"2024-08-02T09:11:06.000Z","dependencies_parsed_at":"2023-07-31T03:23:49.569Z","dependency_job_id":"9cfad160-2470-400a-813f-376d6828e0bd","html_url":"https://github.com/chenyunda218/openapi-go-generator","commit_stats":null,"previous_names":["chenyunda218/openapi-go-gin-genertor","chenyunda218/openapi-go-generator"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/chenyunda218/openapi-go-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenyunda218%2Fopenapi-go-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenyunda218%2Fopenapi-go-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenyunda218%2Fopenapi-go-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenyunda218%2Fopenapi-go-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenyunda218","download_url":"https://codeload.github.com/chenyunda218/openapi-go-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenyunda218%2Fopenapi-go-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272959402,"owners_count":25022056,"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-08-31T02:00:09.071Z","response_time":79,"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-first","apis","gin","go","openapi","webapi"],"created_at":"2024-09-30T15:07:22.507Z","updated_at":"2026-05-07T01:03:20.447Z","avatar_url":"https://github.com/chenyunda218.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openapi-go-generator\n\nopenapi gin server api genertor. openapi-go-generator generate gin server and go interface. Auto binding Parameters. Included in path and in query Parameters.  \nThis project is just started. Please feel free to report any bugs and suggestion.\n\n## CONFIG\n\n| Flat | Description     | Default              |\n| ---- | --------------- | -------------------- |\n| -i   | Input yaml file | ./openapi.yaml       |\n| -o   | Output path     | ./openapigingenertor |\n| -p   | Package name    | openapigingenertor   |\n\n## Schema Support Feature\n\n| Type     | Supported |\n| -------- | --------- |\n| object   | ✓         |\n| string   | ✓         |\n| enum     | ✓         |\n| boolean  | ✓         |\n| int32    | ✓         |\n| int64    | ✓         |\n| float    | ✓         |\n| double   | ✓         |\n| array    | ✓         |\n| required | ✓         |\n| allOf    | ✓         |\n| oneOf    | ✗         |\n\n## Sample\n\n```bash\ngit clone https://github.com/chenyunda218/openapi-go-generator\ncd openapi-go-generator\ngo run main.go -o api -p api -i ./openapi.yaml\n```\n\n## Installation\n\nResource openapi yaml\n\n```yaml\nopenapi: 3.0.3\ninfo:\n  title: Example\n  description: |-\n    Example\n  contact:\n    email: chenyunda218@gmail.com\n  version: 0.0.1\nservers:\n  - url: http://localhost/api/v1\ntags:\n  - name: Pet\n    description: Api of account\npaths:\n  /pets:\n    post:\n      tags:\n        - Pet\n      operationId: CreateCat\n      requestBody:\n        content:\n          application/json:\n            schema:\n              $ref: \"#/components/schemas/Cat\"\n      responses:\n        \"200\":\n          description: Updated\n  /pets/{id}:\n    get:\n      tags:\n        - Pet\n      operationId: GetCat\n      parameters:\n        - name: id\n          in: path\n          schema:\n            type: integer\n            format: int64\n          required: true\n      responses:\n        \"200\":\n          description: Updated\ncomponents:\n  schemas:\n    Dog:\n      type: object\n      properties:\n        bark:\n          type: boolean\n        breed:\n          type: string\n          enum: [Dingo, Husky, Retriever, Shepherd]\n    Cat:\n      type: object\n      properties:\n        hunts:\n          type: boolean\n        age:\n          type: integer\n```\n\nResult\n\n```go\npackage openapigogenerator\n\nimport (\n\t\"strconv\"\n\n\t\"github.com/gin-gonic/gin\"\n)\n\ntype Dog struct {\n\tBark  string `json:\"bark\"`\n\tBreed string `json:\"breed\"`\n}\ntype Cat struct {\n\tHunts string `json:\"hunts\"`\n\tAge   int64  `json:\"age\"`\n}\ntype PetApiInterface interface {\n\tCreateCat(gin_context *gin.Context, gin_body Cat)\n\tGetCat(gin_context *gin.Context, id int64)\n}\n\nfunc CreateCatBinder(api PetApiInterface) func(c *gin.Context) {\n\treturn func(gin_context *gin.Context) {\n\t\tvar cat Cat\n\t\tgin_context.ShouldBindJSON(\u0026cat)\n\t\tapi.CreateCat(gin_context, cat)\n\t}\n}\nfunc GetCatBinder(api PetApiInterface) func(c *gin.Context) {\n\treturn func(gin_context *gin.Context) {\n\t\tid := gin_context.Param(\"id\")\n\t\tapi.GetCat(gin_context, stringToInt64(id))\n\t}\n}\nfunc PetApiInterfaceMounter(gin_router *gin.Engine, gwg_api_label PetApiInterface) {\n\tgin_router.POST(\"/pets\", CreateCatBinder(gwg_api_label))\n\tgin_router.GET(\"/pets/:id\", GetCatBinder(gwg_api_label))\n}\nfunc stringToInt32(s string) int32 {\n\tvalue, _ := strconv.ParseInt(s, 10, 32)\n\treturn int32(value)\n}\nfunc stringToInt64(s string) int64 {\n\tvalue, _ := strconv.ParseInt(s, 10, 64)\n\treturn value\n}\nfunc stringToFloat32(s string) float32 {\n\tvalue, _ := strconv.ParseFloat(s, 32)\n\treturn float32(value)\n}\nfunc stringToFloat64(s string) float64 {\n\tvalue, _ := strconv.ParseFloat(s, 64)\n\treturn value\n}\n\n```\n\nYou should implement PetApiInterface interface.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"genen/api\"\n\n\t\"github.com/gin-gonic/gin\"\n)\n\ntype PetApi struct{}\n\nfunc (PetApi) CreateCat(c *gin.Context, cat api.Cat) {\n\tfmt.Println(cat)\n}\n\nfunc (PetApi) GetCat(c *gin.Context, id int64) {\n\tfmt.Println(id)\n}\n\nfunc main() {\n\trouter := gin.Default()\n\tapi.PetApiInterfaceMounter(router, \u0026PetApi{})\n\trouter.Run(\":8081\")\n}\n\n```\n\n## Feature\n\n- Generate go interface\n- Generate gin router\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenyunda218%2Fopenapi-go-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenyunda218%2Fopenapi-go-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenyunda218%2Fopenapi-go-generator/lists"}