Aiursoft.DocGenerator 7.0.1
ASP.NET Core API Document Generator
A basic API document generator for ASP.NET Core applications. Open source, offline and free.
Features
- Generate Markdown
- Generate Json
Supports
- ASP.NET Core 6.0
How to use
First, install Aiursoft.DocGenerator
to your ASP.NET Core project from nuget.org:
dotnet add package Aiursoft.DocGenerator
Simply add this line in your Startup.cs
:
using Aiursoft.DocGenerator.Services;
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// ...
// your middlewares
// ...
app.UseAiursoftDocGenerator(); // <- Add this.
}
Start your application and browse:
/doc
It just returns your document in JSON format.
[{
"ControllerName": "HomeController",
"ActionName": "Index",
"AuthRequired": false,
"IsPost": false,
"Arguments": [],
"PossibleResponses": ["{\"code\":0,\"message\":\"success.\"}"]
}]
That's all! Happy coding!
Continue? Try runing the example project! Or continue reading.
Customization and API
Change document output address
app.UseAiursoftDocGenerator(options =>
{
// Default value is '/doc'. You can change it to other path.
options.DocAddress = "/my-doc";
});
Change document output format
app.UseAiursoftDocGenerator(options =>
{
// Default format is JSON. You can change it to markdown.
options.Format = DocFormat.Markdown;
});
Set global possible responses
app.UseAiursoftDocGenerator(options =>
{
// Default global possible response is an empty list.
options.GlobalPossibleResponse.Add(new { code = 0, message = "success." });
});
Set possible response for one API
When you can ensure the possible response for one API, add this line to your action:
[Produces(typeof(ResponseModel))] // <- add this in your controller.
public IActionResult HasOutput()
{
var model = new ResponseModel(); // <- your own class and logic
return Json(model);
}
Document generation filter
By default, only controllers and actions with [GenerateDoc]
attributes will be generated.
To mark a controller or action which generates document, add attribute [GenerateDoc]
like this:
using Aiursoft.DocGenerator.Attribute;
[GenerateDoc] // Add this, the entire controller will generate document.
public class HomeController : Controller
{
[GenerateDoc] // Add this, the action will generate document.
public IActionResult MyAPI()
{
return Json(null);
}
}
You can change that logic to your own filter:
app.UseAiursoftDocGenerator(options =>
{
options.IsAPIAction = (action, controller) =>
{
// Your own logic. Return bool.
return action.CustomAttributes.Any(t => t.AttributeType == typeof(GenerateDoc));
};
}
Authorized action detector
If your API is authorized required, we can detect that in the document. And you can customzie the logic:
using Microsoft.AspNetCore.Authorization;
app.UseAiursoftDocGenerator(options =>
{
options.JudgeAuthorized = (action, controller) =>
{
// Your own logic here. Return bool.
return
action.CustomAttributes.Any(t => t.AttributeType == typeof(AuthorizeAttribute)) ||
controller.CustomAttributes.Any(t => t.AttributeType == typeof(AuthorizeAttribute));
};
}
How to contribute
There are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.
Even if you with push rights on the repository, you should create a personal fork and create feature branches there when you need them. This keeps the main repository clean and your workflow cruft out of sight.
We're also interested in your feedback on the future of this project. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly.
Showing the top 20 packages that depend on Aiursoft.DocGenerator.
Packages | Downloads |
---|---|
Aiursoft.SDK
The base class, tools and extends for Aiursoft web apps.
|
205 |
Aiursoft.SDK
The base class, tools and extends for Aiursoft web apps.
|
11 |
Aiursoft.SDK
The base class, tools and extends for Aiursoft web apps.
|
10 |
Aiursoft.SDK
The base class, tools and extends for Aiursoft web apps.
|
9 |
Aiursoft.SDK
All Aiursoft API implementations for all apps which need to integrate with Aiursoft.
|
9 |
Aiursoft.SDK
The base class, tools and extends for Aiursoft web apps.
|
8 |
.NET 7.0
- Aiursoft.DocGenerator.Abstractions (>= 7.0.1)
- Aiursoft.Scanner.Abstractions (>= 7.0.1)
- Newtonsoft.Json (>= 13.0.3)
Version | Downloads | Last updated |
---|---|---|
8.0.2 | 152 | 10/26/2024 |
8.0.1 | 664 | 03/25/2024 |
8.0.0 | 4 | 04/29/2024 |
7.0.3 | 11 | 03/31/2024 |
7.0.2 | 8 | 04/29/2024 |
7.0.1 | 201 | 03/26/2024 |
7.0.0 | 10 | 04/02/2024 |
6.0.26 | 7 | 04/02/2024 |
6.0.25 | 13 | 04/02/2024 |
6.0.24 | 11 | 04/02/2024 |
6.0.22 | 8 | 04/02/2024 |
6.0.21 | 7 | 04/02/2024 |
6.0.20 | 5 | 04/02/2024 |
6.0.19 | 8 | 03/27/2024 |
6.0.18 | 9 | 04/02/2024 |
6.0.17 | 7 | 04/02/2024 |
6.0.16 | 6 | 04/02/2024 |
6.0.15 | 6 | 04/02/2024 |
6.0.14 | 6 | 04/02/2024 |
6.0.13 | 7 | 04/02/2024 |
6.0.12 | 7 | 04/02/2024 |
6.0.11 | 7 | 04/02/2024 |
6.0.10 | 6 | 04/02/2024 |
6.0.9 | 7 | 04/02/2024 |
6.0.8 | 5 | 04/02/2024 |
6.0.7 | 6 | 04/02/2024 |
6.0.6 | 7 | 04/01/2024 |
6.0.5 | 6 | 04/02/2024 |
6.0.0 | 9 | 04/02/2024 |
5.0.9 | 6 | 04/02/2024 |
5.0.8 | 6 | 04/02/2024 |
5.0.7 | 7 | 04/02/2024 |
5.0.6 | 6 | 04/02/2024 |
5.0.5 | 5 | 04/02/2024 |
5.0.4 | 7 | 04/02/2024 |
5.0.3 | 6 | 03/31/2024 |
5.0.2 | 8 | 04/02/2024 |
5.0.1 | 5 | 04/02/2024 |
5.0.0 | 8 | 04/02/2024 |
3.2.11 | 7 | 04/02/2024 |
3.2.10 | 7 | 04/02/2024 |
3.2.9 | 8 | 04/02/2024 |
3.2.8 | 8 | 04/01/2024 |
3.2.7 | 6 | 04/02/2024 |
3.2.6 | 7 | 03/28/2024 |
3.2.5 | 5 | 04/02/2024 |
3.2.4 | 5 | 04/02/2024 |
3.2.3 | 8 | 04/02/2024 |
3.2.2 | 8 | 04/02/2024 |
3.2.1 | 9 | 04/02/2024 |
3.2.0 | 8 | 04/02/2024 |
3.1.14 | 7 | 04/02/2024 |
3.1.13 | 7 | 04/02/2024 |
3.1.12 | 7 | 04/02/2024 |
3.1.11 | 6 | 04/02/2024 |
3.1.10 | 6 | 04/02/2024 |
3.1.9 | 9 | 04/02/2024 |
3.1.8 | 7 | 04/29/2024 |
3.1.7 | 7 | 04/02/2024 |
3.1.6 | 5 | 04/02/2024 |
3.1.5 | 9 | 04/02/2024 |
3.1.4 | 7 | 04/02/2024 |
3.1.3 | 7 | 04/02/2024 |
3.1.2.2 | 7 | 04/02/2024 |
3.1.2.1 | 6 | 04/02/2024 |
3.1.2 | 6 | 04/02/2024 |
3.1.1.8 | 6 | 04/02/2024 |
3.1.1.7 | 6 | 04/02/2024 |
3.1.1.6 | 5 | 04/02/2024 |
3.1.1.5 | 5 | 04/02/2024 |
3.1.1.4 | 6 | 04/02/2024 |
3.1.1.2 | 6 | 04/02/2024 |
3.1.1 | 6 | 04/02/2024 |