{"id":37034687,"url":"https://github.com/tdudek1/autoapi","last_synced_at":"2026-01-14T04:03:48.565Z","repository":{"id":37601622,"uuid":"142725861","full_name":"tdudek1/AutoAPI","owner":"tdudek1","description":"Automatic REST api library for Entity Framework sets in .Net Core","archived":false,"fork":false,"pushed_at":"2023-06-27T23:13:42.000Z","size":9709,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T17:10:49.656Z","etag":null,"topics":["api","dotnet-core","entity-framework-core","nuget","rest-api"],"latest_commit_sha":null,"homepage":"","language":"C#","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/tdudek1.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}},"created_at":"2018-07-29T02:53:03.000Z","updated_at":"2025-02-05T17:24:54.000Z","dependencies_parsed_at":"2022-08-25T22:12:20.627Z","dependency_job_id":null,"html_url":"https://github.com/tdudek1/AutoAPI","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/tdudek1/AutoAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdudek1%2FAutoAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdudek1%2FAutoAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdudek1%2FAutoAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdudek1%2FAutoAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdudek1","download_url":"https://codeload.github.com/tdudek1/AutoAPI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdudek1%2FAutoAPI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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","dotnet-core","entity-framework-core","nuget","rest-api"],"created_at":"2026-01-14T04:03:48.032Z","updated_at":"2026-01-14T04:03:48.556Z","avatar_url":"https://github.com/tdudek1.png","language":"C#","readme":"# Automatic REST api library for EF entities in .Net Core\n\nThis library automatically generates RESTful API for DbSets in DbContext.  This is very much work in progress right now so feel free to submit issues.\n\n[![Build status](https://ci.appveyor.com/api/projects/status/ar22x62t99bdv09v/branch/master?svg=true)](https://ci.appveyor.com/project/tdudek1/autoapi/branch/master)\n\n**3.2 update to dotnet 6**\n\n - update to dotnet 6 and ef 6\n - fixed exception when key was a guid\n - added support for [Keyless] entities\n\n**3.1 Update to dotnet 5** \n\n - switches to use System.Text.Json from Json.NET - Newtonsoft for serialization and this make cause breaking changes\n - switches swagger support to use Microsoft.OpenApi.Models;\n - added extension method to configure System.Text.Json serializer options\n\n**Version 2 breaks compatilbity as it uses a middleware instead of a controller to handle requests**\n\n### Nuget\n\nhttps://www.nuget.org/packages/Auto.Rest.API/\n\n\n### Getting Started\n\nConfigure Auto API Service \n\nIn Startup.cs ConfigureServices (path indicates base bath for db context)\n\n```c#\npublic void ConfigureServices(IServiceCollection services)\n{\n    ...\n    //generic argument is DbContext\n    services.AddAutoAPI\u003cDataContext\u003e(options =\u003e\n    {\n        options.Path = \"/api/data\";\n        //optional \n        options.JsonSerializerOptions = new JsonSerializerOptions() { WriteIndented = true };\n    });\n\n    //register db context\n    services.AddDbContext\u003cDataContext\u003e(o =\u003e o.UseSqlServer(Configuration.GetConnectionString(\"Data\")));\n}\n```\n\n\nRegister Middleware\n\nIn Startup.cs Configure\n\n```c# \npublic void Configure(IApplicationBuilder app, IHostingEnvironment env)\n{\n    ...\n    app.UseAutoAPI();\n}\n```\n\n\nAnnotate Data Context\n\n\n```c#\npublic class DataContext : DbContext\n{\n    public DataContext(DbContextOptions\u003cDataContext\u003e options) : base(options)\n    {\n\n    }\n    \n    [AutoAPIEntity(Route = \"authors\", POSTPolicy = \"IsAdmin\", Authorize = true)]\n    public DbSet\u003cAuthor\u003e Authors { get; set; }\n    [AutoAPIEntity(Route = \"Books\")]\n    public DbSet\u003cBook\u003e Books { get; set; }\n}\n```\n\n##### Access at\n\n```\nRead all                GET     /api/data/authors \nRead by id              GET     /api/data/authors/1 \nCount                   GET     /api/data/authors/count\nPagedResult             GET     /api/data/authors/pagedresult\nFilter/Sort/Paging      GET     /api/data/authors?filter[Name][like]=J.R.R.Tolkien\u0026sort[Id]=desc\u0026pageSize=10\u0026page=2\nCreate                  POST    /api/data/authors\nUpdate                  PUT     /api/data/authors/1\nDelete                  DELETE  /api/data/authors/1\n```\n\n##### Authentication and Authorization\n\nTo require user to be authenticated set Authorize property of the AutoAPIEntity attribute to true.\n\nPolicy based authorization can be confgured by setting policy name property for entity or per http verb.\n\n```c#\n    \n[AutoAPIEntity(Route = \"authors\", POSTPolicy = \"IsAdmin\", Authorize = true, ExposePagedResult = true)]\npublic DbSet\u003cAuthor\u003e Authors { get; set; }\n    \n```\n\n\n\n##### Swagger\n\nAdd AutoApi routes to swagger document with DocumentFilter using **Swashbuckle.AspNetCore** (https://github.com/domaindrivendev/Swashbuckle.AspNetCore)\n\n```c#\n\nservices.AddSwaggerGen(a=\u003e\n{\n    a.DocumentFilter\u003cAutoAPISwaggerDocumentFilter\u003e();\n});\n\n```\n\n##### More filters\n\nYou can specify comparison operators in query string like this\n\n````\n?filter[propertyName][operator] = value\n````\n\nSupported operators are \n\n - String Properties \n   - eq (Equal) neq (Not Equal) like (Like) nlike (Not Like) in (In) nin (Not In)\n - Guid Properties \n   - eq (Equal) neq (Not Equal) in (In) nin (Not In)\n - Value Type Properties\n\t- eq (Equal) neq (Not Equal) gt (Greater Than) lt (Less than) gteq (Greater Than or Equal) lteq (Less Than or Equal) in (In) nin (Not In)\n\nBy default multiple filters are joined with an AND operator to use OR use ?operator=or \n\nFilters can also be used with the count endpoint\n\n##### Paged Result\n\nYou can access paged result like this\n\n````\n/data/api/authors/pagedresult?page=1\u0026pageSize=2\n````\n\nThis will produce result like below that will include current page, page size, number of pages and total items.\n\n```json\n{\n  \"items\": [\n    {\n      \"id\": 1,\n      \"name\": \"Ernest Hemingway\",\n      \"books\": null,\n      \"dateOfBirth\": \"1899-07-21T00:00:00\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"Stephen King\",\n      \"books\": null,\n      \"dateOfBirth\": \"1947-09-21T00:00:00\"\n    }\n  ],\n  \"page\": 1,\n  \"pageCount\": 1,\n  \"pageSize\": 2,\n  \"total\": 2\n}\n```\n\n\n\n##### Include related entities\n\nTo include related entities you can use the include parameter\n\n````\n/data/api/authors?include=books\n````\n\n#### License\n\nhttps://opensource.org/licenses/GPL-3.0\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdudek1%2Fautoapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdudek1%2Fautoapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdudek1%2Fautoapi/lists"}