Skip to content

Commit 3aad466

Browse files
committed
add documentation
1 parent fa448f5 commit 3aad466

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

docs/getting-started/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ Install-Package JsonApiDotnetCore
1919
```xml
2020
<ItemGroup>
2121
<!-- Be sure to check NuGet for the latest version # -->
22-
<PackageReference Include="JsonApiDotNetCore" Version="4.0.0" />
22+
<PackageReference Include="JsonApiDotnetCore" Version="4.0.0" />
2323
</ItemGroup>
2424
```

docs/usage/openapi.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# OpenAPI
2+
3+
You can describe your API with an OpenAPI specification using the [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) integration for JsonApiDotNetCore.
4+
5+
## Installation
6+
7+
Install the `JsonApiDotnetCore.OpenApi` NuGet package.
8+
9+
### CLI
10+
11+
```
12+
dotnet add package JsonApiDotnetCore.OpenApi
13+
```
14+
15+
### Visual Studio
16+
17+
```powershell
18+
Install-Package JsonApiDotnetCore.OpenApi
19+
```
20+
21+
### *.csproj
22+
23+
```xml
24+
<ItemGroup>
25+
<!-- Be sure to check NuGet for the latest version # -->
26+
<PackageReference Include="JsonApiDotnetCore.OpenApi" Version="4.0.0" />
27+
</ItemGroup>
28+
```
29+
30+
## Usage
31+
32+
Add the integration in your `Startup` class.
33+
34+
```c#
35+
public class Startup
36+
{
37+
public void ConfigureServices(IServiceCollection services)
38+
{
39+
IMvcCoreBuilder builder = services.AddMvcCore();
40+
services.AddJsonApi<AppDbContext>(mvcBuilder: builder);
41+
42+
// Adds the Swashbuckle integration
43+
services.AddOpenApi(builder);
44+
}
45+
46+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
47+
{
48+
app.UseRouting();
49+
app.UseJsonApi();
50+
51+
// Adds the Swashbuckle middleware
52+
app.UseSwagger();
53+
54+
app.UseEndpoints(endpoints => endpoints.MapControllers());
55+
}
56+
}
57+
```
58+
59+
By default, the OpenAPI specification will be available at `http://localhost:<port>/swagger/v1/swagger.json`.
60+
61+
Swashbuckle also ships with [SwaggerUI](https://swagger.io/tools/swagger-ui/), tooling for a generated documentation page. This can be enabled by adding the following to your `Startup` class.
62+
63+
```c#
64+
// Startup.cs
65+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
66+
{
67+
app.UseSwaggerUI();
68+
}
69+
```
70+
71+
By default, SwaggerUI will be available at `http://localhost:<port>/swagger`.
72+

docs/usage/toc.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
## [Resource Repositories](extensibility/repositories.md)
3131
## [Middleware](extensibility/middleware.md)
3232
## [Query Strings](extensibility/query-strings.md)
33+
34+
# [OpenAPI](openapi.md)

0 commit comments

Comments
 (0)