{"id":25050600,"url":"https://github.com/devel0/example-webapi","last_synced_at":"2026-04-27T18:05:38.147Z","repository":{"id":272506944,"uuid":"916828376","full_name":"devel0/example-webapi","owner":"devel0","description":"sample webapi","archived":false,"fork":false,"pushed_at":"2025-03-07T19:34:47.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-02T20:42:59.115Z","etag":null,"topics":["aspnetcore","controller","csharp","lifetime","serilog","services","swagger"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devel0.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-01-14T20:45:35.000Z","updated_at":"2025-03-07T19:34:51.000Z","dependencies_parsed_at":"2025-01-14T21:43:46.101Z","dependency_job_id":"b2609a2a-ab87-41d1-9495-d85be1f014a9","html_url":"https://github.com/devel0/example-webapi","commit_stats":null,"previous_names":["devel0/example-webapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devel0/example-webapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-webapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-webapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-webapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-webapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devel0","download_url":"https://codeload.github.com/devel0/example-webapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-webapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32348058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T17:12:42.749Z","status":"ssl_error","status_checked_at":"2026-04-27T17:12:41.658Z","response_time":128,"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":["aspnetcore","controller","csharp","lifetime","serilog","services","swagger"],"created_at":"2025-02-06T09:16:57.765Z","updated_at":"2026-04-27T18:05:38.131Z","avatar_url":"https://github.com/devel0.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# example web api\n\n- [features](#features)\n- [quickstart](#quickstart)\n- [graceful shutdown](#graceful-shutdown)\n- [json camelcase](#json-camelcase)\n- [test websocket server](#test-websocket-server)\n- [seealso](#seealso)\n- [how this project was built](#how-this-project-was-built)\n\n## features\n\nsame as `dotnew new webapi` plus:\n- serilog\n- swagger ( dark theme ) with xml generated doc from code and custom document filter to add more custom types\n- injectable services into controllers\n- lifetime with cts to deal with graceful shutdown\n- code casing extensions and util service for json camelcase configuration\n- websocket server\n\n## quickstart\n\n- install repo as template\n\n```sh\ngit clone https://github.com/devel0/example-webapi.git\ncd example-webapi\ndotnet new install .\ncd ..\n```\n\n- create project from template\n\n```sh\ndotnet new webapi-skel -n project-folder --namespace My.Some\ncd project-folder\ndotnet run\n```\n\n## graceful shutdown\n\n```sh\ndevel0@mini:~/opensource/example-webapi$ dn run\n[19:12:49 INF] Backend application started\n[19:12:49 INF] Application started\n[19:12:49 INF] Environment: Production\n[19:12:49 INF] Listening on http://localhost:5000\n^C\n[19:12:50 INF] Backend application stopping\n[19:12:50 INF] Backend application stopped\n[19:12:50 INF] Application stopping\n[19:12:50 INF] Graceful shutdown in progress\n[19:12:50 INF] Fake 3 sec wait\n[19:12:53 INF] Graceful shutdown completed\n[19:12:53 INF] Application stopped\n```\n\n## json camelcase\n\ninjecting `IUtilService` there is a ready to use `JavaSerializerSettings` method to pass a configured json options object:\n\n```csharp\nvar obj = JsonSerializer.Deserialize\u003cNfo\u003e(res, util.JavaSerializerSettings());\n```\n\n## test websocket server\n\ntry to paste `{\"messageType\":\"Ping\"}` to get Pong response\n\n```sh\n$ iocat ws://localhost:5000/api/Sample/SampleWsData\n\u003e Connection to ws://localhost:5000/api/ws succeeded!\n{\"msg\":\"test msg 2/8/2025 10:52:56\\u202FPM\",\"messageType\":\"SomeEvent\"}\n{\"msg\":\"test msg 2/8/2025 10:52:57\\u202FPM\",\"messageType\":\"SomeEvent\"}\n{\"msg\":\"test msg 2/8/2025 10:52:58\\u202FPM\",\"messageType\":\"SomeEvent\"}\n{\"messageType\":\"Ping\"}\n\u003e {\"msg\":null,\"messageType\":\"Pong\"}\n{\"msg\":\"test msg 2/8/2025 10:52:59\\u202FPM\",\"messageType\":\"SomeEvent\"}\n{\"msg\":\"test msg 2/8/2025 10:53:00\\u202FPM\",\"messageType\":\"SomeEvent\"}\n{\"msg\":\"test msg 2/8/2025 10:53:01\\u202FPM\",\"messageType\":\"SomeEvent\"}\n{\"msg\":\"test msg 2/8/2025 10:53:02\\u202FPM\",\"messageType\":\"SomeEvent\"}\nshell.on SIGINT\n```\n\n## seealso\n\nfor a more advanced scenario [example-webapi-with-auth](https://github.com/devel0/example-webapp-with-auth)\n\n## how this project was built\n\n```sh\ndotnet new webapi -n ExampleWebApi -f net9.0 -controllers --exclude-launch-settings\ncd ExampleWebApi\ndotnet new gitignore\ndotnet add package Serilog.Extensions.Hosting --version 9.0.0\ndotnet add package Serilog.Settings.Configuration --version 9.0.0\ndotnet add package Serilog.Sinks.Console --version 6.0.0\ndotnet add package Swashbuckle.AspNetCore --version 7.2.0\ndotnet add package Swashbuckle.AspNetCore.Annotations --version 7.2.0\ndotnet add package Unchase.Swashbuckle.AspNetCore.Extensions --version 2.7.2\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevel0%2Fexample-webapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevel0%2Fexample-webapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevel0%2Fexample-webapi/lists"}