{"id":16430905,"url":"https://github.com/nightapes/go-rest","last_synced_at":"2025-10-08T11:43:51.170Z","repository":{"id":50124598,"uuid":"373538379","full_name":"Nightapes/go-rest","owner":"Nightapes","description":"Simple tool to generate openapi definition in go","archived":false,"fork":false,"pushed_at":"2023-05-22T08:39:42.000Z","size":56,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T03:51:08.608Z","etag":null,"topics":["go","golang","openapi","rest","rest-api","swagger"],"latest_commit_sha":null,"homepage":"https://nightapes.github.io/go-rest/","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/Nightapes.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":"2021-06-03T14:34:42.000Z","updated_at":"2023-07-07T01:54:04.000Z","dependencies_parsed_at":"2024-06-19T17:11:19.818Z","dependency_job_id":"5b4437e7-5790-474d-9f67-b8d95778ab5f","html_url":"https://github.com/Nightapes/go-rest","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/Nightapes/go-rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nightapes%2Fgo-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nightapes%2Fgo-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nightapes%2Fgo-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nightapes%2Fgo-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nightapes","download_url":"https://codeload.github.com/Nightapes/go-rest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nightapes%2Fgo-rest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278938017,"owners_count":26072242,"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-10-08T02:00:06.501Z","response_time":56,"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":["go","golang","openapi","rest","rest-api","swagger"],"created_at":"2024-10-11T08:28:42.228Z","updated_at":"2025-10-08T11:43:51.119Z","avatar_url":"https://github.com/Nightapes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-rest\n\nGenerate openapi definition from code.\n\n## Usage\n\n```go\nimport \"github.com/Nightapes/go-rest/pkg/openapi\"\n```\n\n```go\npackage main \n\nimport \"github.com/Nightapes/go-rest/pkg/openapi\"\n\nvar GetUser = \u0026openapi.Get{\n\tSummary:        \"Get User\",\n\tDescription:    \"Get User with given ID\",\n\tOperationID:    \"GetMyTest\",\n\tTags:           []string{\"UserService\"},\n\tAuthentication: map[string][]string{\"mybasic\": nil, \"mybearer\": {\"users:read\"}},\n\tResponse: map[string]openapi.MethodResponse{\n\t\t\"200\": {\n\t\t\tDescription: \"The response with userID\",\n\t\t\tValue: \u0026User{\n\t\t\t\tUserID: \"exampleID\",\n\t\t\t},\n\t\t},\n\t},\n\tHeaders: []openapi.Parameter{{Description: \"My custom header\", Name: \"test-header\", Required: false, Type: openapi.INTEGER}},\n\tPath: openapi.NewPathBuilder().\n\t\tAdd(\"users\").\n\t\tAddParameter(\"userId\", openapi.STRING, \"UserID\").\n\t\tWithQueryParameter(\"filter\", openapi.STRING, \"Filter stuff\", false),\n\tHandlerFunc: func(writer http.ResponseWriter, request *http.Request) {\n\t\tuser := \u0026User{UserID: \"userID\"}\n\t\tresp, _ := json.Marshal(user)\n\t\twriter.Write(resp)\n\t},\n}\n\nfunc main() {\n\t\napi := openapi.NewOpenAPI()\napi.Title = \"MyAPI\"\napi.Get(GetUser)\n...\n}\n```\n\nSee `./example` for complete setup \n\n## Authentication\n\nMiddleware to get authentication is available for chi `router`\n\n\n```go\nauthMiddleware := api.ChiAuthMiddleware(func(authName string, scopes []string, r *http.Request) bool {\n    log.Printf(\"Auth check %s %s\", authName, scopes)\n    if authName == \"mybearer\" {\n        return false\n    }\n    return true\n})\n\nr := chi.NewRouter()\nfor _, handleConfig := range api.GetHandleFunc() {\n    log.Printf(\"Add func %s %s\", handleConfig.Method, handleConfig.Path)\n    r.With(authMiddleware).MethodFunc(handleConfig.Method, handleConfig.Path, handleConfig.HandlerFunc)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightapes%2Fgo-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightapes%2Fgo-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightapes%2Fgo-rest/lists"}