Skip to content

Commit 583958b

Browse files
Merge branch 'master' into dotnet-vnext
2 parents 763e98f + ac7b877 commit 583958b

35 files changed

Lines changed: 7053 additions & 64 deletions

File tree

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"rollForward": false
1818
},
1919
"meziantou.framework.nugetpackagevalidation.tool": {
20-
"version": "1.0.44",
20+
"version": "1.0.45",
2121
"commands": [
2222
"meziantou.validate-nuget-package"
2323
],

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
steps:
166166

167167
- name: Download packages
168-
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
168+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
169169
with:
170170
name: packages-Windows
171171

@@ -225,7 +225,7 @@ jobs:
225225
steps:
226226

227227
- name: Download packages
228-
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
228+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
229229
with:
230230
name: packages-Windows
231231

@@ -259,7 +259,7 @@ jobs:
259259
steps:
260260

261261
- name: Download packages
262-
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
262+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
263263
with:
264264
name: packages-Windows
265265

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ jobs:
3030
show-progress: false
3131

3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
33+
uses: github/codeql-action/init@b1bff81932f5cdfc8695c7752dcee935dcd061c8 # v4.33.0
3434
with:
3535
languages: csharp
3636
build-mode: none
3737

3838
- name: Perform CodeQL Analysis
39-
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
39+
uses: github/codeql-action/analyze@b1bff81932f5cdfc8695c7752dcee935dcd061c8 # v4.33.0
4040
with:
4141
category: '/language:csharp'

.github/workflows/ossf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ jobs:
4141
retention-days: 5
4242

4343
- name: Upload to code-scanning
44-
uses: github/codeql-action/upload-sarif@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
44+
uses: github/codeql-action/upload-sarif@b1bff81932f5cdfc8695c7752dcee935dcd061c8 # v4.33.0
4545
with:
4646
sarif_file: results.sarif

.github/workflows/update-dotnet-sdk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111

1212
jobs:
1313
update-dotnet-sdk:
14-
uses: martincostello/update-dotnet-sdk/.github/workflows/update-dotnet-sdk.yml@d4f29d2646a47463bc610beab7738ba512df9976 # v5.0.1
14+
uses: martincostello/update-dotnet-sdk/.github/workflows/update-dotnet-sdk.yml@7f7b459c48652a0e24f154bbe6dc16a5c7409b1b # v5.0.2
1515
permissions:
1616
contents: write
1717
pull-requests: write

AGENTS.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Coding Agent Instructions
2+
3+
This file provides guidance to agents when working with code in this repository.
4+
5+
## Overview
6+
7+
Swashbuckle.AspNetCore is an OpenAPI (Swagger) tooling library for ASP.NET Core. It generates OpenAPI 2.0/3.0/3.1 documents
8+
from ASP.NET Core routes/controllers/models at runtime, and serves the swagger-ui and ReDoc UIs as embedded middleware.
9+
10+
It targets the currently released and supported versions of .NET.
11+
12+
## Commands
13+
14+
**Build and test (full pipeline):**
15+
16+
```powershell
17+
./build.ps1
18+
```
19+
20+
This runs `dotnet pack` followed by `dotnet test`.
21+
22+
**Build only:**
23+
24+
```bash
25+
dotnet build
26+
```
27+
28+
**Run all tests:**
29+
30+
```bash
31+
dotnet test
32+
```
33+
34+
**Run tests for a specific project:**
35+
36+
```bash
37+
dotnet test test/Swashbuckle.AspNetCore.SwaggerGen.Test/
38+
dotnet test test/Swashbuckle.AspNetCore.IntegrationTests/
39+
```
40+
41+
**Run a single test:**
42+
43+
```bash
44+
dotnet test test/Swashbuckle.AspNetCore.SwaggerGen.Test/ --filter "FullyQualifiedName~MethodName"
45+
```
46+
47+
**Restore .NET tools:**
48+
49+
```bash
50+
dotnet tool restore
51+
```
52+
53+
**Update snapshot files (Verify tests):**
54+
55+
When snapshot-based tests fail due to intentional changes, update snapshots by running tests with the
56+
`VERIFY_AUTO_ACCEPT_CHANGES=true` environment variable or by accepting the diff via the Verify framework's mechanism.
57+
58+
## Architecture
59+
60+
### Source packages (`src/`)
61+
62+
| Project | Purpose |
63+
| --- | --- |
64+
| `Swashbuckle.AspNetCore.Swagger` | Core middleware that serves OpenAPI JSON endpoints; depends on `Microsoft.OpenApi` |
65+
| `Swashbuckle.AspNetCore.SwaggerGen` | OpenAPI document generation engine — the main logic layer |
66+
| `Swashbuckle.AspNetCore.SwaggerUI` | Embeds swagger-ui as ASP.NET Core middleware (bundles from npm) |
67+
| `Swashbuckle.AspNetCore.ReDoc` | Embeds ReDoc as ASP.NET Core middleware (bundles from npm) |
68+
| `Swashbuckle.AspNetCore.Annotations` | Optional attributes (`SwaggerOperation`, `SwaggerResponse`, etc.) |
69+
| `Swashbuckle.AspNetCore.Newtonsoft` | Newtonsoft.Json support replacing the default System.Text.Json contract resolver |
70+
| `Swashbuckle.AspNetCore.Cli` | `dotnet swagger` CLI tool for offline document generation |
71+
| `Swashbuckle.AspNetCore.ApiTesting` | Assertion helpers for API contract testing |
72+
| `Swashbuckle.AspNetCore` | Meta-package referencing the above |
73+
74+
### Key generation pipeline (`SwaggerGen`)
75+
76+
1. **`SwaggerGenerator`** — entry point; uses `IApiDescriptionGroupCollectionProvider` (ASP.NET Core's API explorer) to enumerate endpoints, then calls `SchemaGenerator` for each type.
77+
2. **`SchemaGenerator`** — converts .NET types to `IOpenApiSchema` objects. Uses `ISerializerDataContractResolver` to understand how the serializer will represent types.
78+
3. **`JsonSerializerDataContractResolver`** — the default resolver backed by System.Text.Json; `NewtonsoftDataContractResolver` (in the Newtonsoft package) is the alternative.
79+
4. **`SchemaRepository`** — accumulates reusable schemas into `components/schemas` to avoid duplication. Schemas are referenced by `$ref` after first generation.
80+
5. **Filters**`IDocumentFilter`, `IOperationFilter`, `IParameterFilter`, `IRequestBodyFilter`, `ISchemaFilter` (sync and async variants) are applied at each pipeline stage and are the primary extension points.
81+
82+
### Test structure (`test/`)
83+
84+
- `Swashbuckle.AspNetCore.SwaggerGen.Test` — unit tests for schema and swagger generation; uses xUnit v3 and Verify for snapshot testing; snapshots stored under `snapshots/{tfm}/`.
85+
- `Swashbuckle.AspNetCore.IntegrationTests` — end-to-end tests running real `WebApplication` instances; also uses Verify snapshots and Playwright for UI tests.
86+
- `WebSites/` — sample ASP.NET Core apps used as test fixtures (Basic, MinimalApp, MultipleVersions, OAuth2Integration, etc.).
87+
- `Swashbuckle.AspNetCore.TestSupport` — shared test helpers.
88+
89+
### Public API tracking
90+
91+
Packable projects use `Microsoft.CodeAnalysis.PublicApiAnalyzers`. Any change to the public API surface must be reflected in `PublicAPI/PublicAPI.Unshipped.txt` (and per-TFM variants). Breaking changes require a baseline comparison against `PackageValidationBaselineVersion`.
92+
93+
### Warnings and strictness
94+
95+
`TreatWarningsAsErrors` is enabled globally. `Nullable` annotations are not yet enabled.
96+
97+
## Key conventions
98+
99+
- Central package version management via `Directory.Packages.props`.
100+
- The primary serializer integration is System.Text.Json; Newtonsoft.Json is opt-in via the separate package.
101+
- Integration test snapshots under `test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/` are linted with Spectral in CI to validate OpenAPI correctness.
102+
- SwaggerUI and ReDoc bundles are managed via npm (`package.json` in their respective `src/` directories).
103+
104+
## General guidelines
105+
106+
- Always ensure code compiles with no warnings or errors and tests pass locally before pushing changes.
107+
- Do not change the public API unless specifically requested.
108+
- Do not use APIs marked with `[Obsolete]`.
109+
- Bug fixes should **always** include a test that would fail without the corresponding fix.
110+
- Do not introduce new dependencies unless specifically requested.
111+
- Do not update existing dependencies unless specifically requested.

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<PackageVersion Include="NSubstitute" Version="5.3.0" />
2828
<PackageVersion Include="NSwag.CodeGeneration.CSharp" Version="14.6.3" />
2929
<PackageVersion Include="NSwag.MSBuild" Version="14.6.3" />
30-
<PackageVersion Include="ReportGenerator" Version="5.5.3" />
31-
<PackageVersion Include="Verify.XunitV3" Version="31.13.2" />
30+
<PackageVersion Include="ReportGenerator" Version="5.5.4" />
31+
<PackageVersion Include="Verify.XunitV3" Version="31.13.5" />
3232
<PackageVersion Include="xunit" Version="2.9.3" />
3333
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
3434
<PackageVersion Include="xunit.v3.mtp-off" Version="3.2.2" />

src/Swashbuckle.AspNetCore.Cli/HostingApplication.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ void OnEntryPointExit(Exception exception)
8888

8989
return services;
9090
}
91-
catch (InvalidOperationException)
91+
catch (InvalidOperationException ex)
9292
{
93-
// We're unable to resolve the host, swallow the exception and return null
93+
// We're unable to resolve the host, log the exception and return null
94+
Console.Error.WriteLine(ex.ToString());
9495
}
9596

9697
return null;

src/Swashbuckle.AspNetCore.ReDoc/package-lock.json

Lines changed: 31 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)