Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ PublishProfiles
*.GhostDoc.xml
*.log
*.nupkg
!.packages/*.nupkg
*.opensdf
*.[Pp]ublish.xml
*.publishproj
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<clear />
<add key="benchmarkdotnet" value="https://www.myget.org/F/benchmarkdotnet/api/v3/index.json" />
<add key="domaindrivendev" value="https://www.myget.org/F/domaindrivendev/api/v3/index.json" />
<add key="local" value=".packages" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
Expand All @@ -14,6 +15,9 @@
<packageSource key="domaindrivendev">
<package pattern="Swashbuckle.AspNetCore*" />
</packageSource>
<packageSource key="local">
<package pattern="Swashbuckle.AspNetCore*" />
</packageSource>
<packageSource key="NuGet">
<package pattern="*" />
</packageSource>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.100-preview.3.25201.16",
"version": "10.0.100-preview.4.25258.110",
"allowPrerelease": false,
"rollForward": "latestMajor"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ public static IServiceCollection AddAspNetCoreOpenApi(this IServiceCollection se
Type = SecuritySchemeType.Http,
};

var reference = new OpenApiSecuritySchemeReference("Bearer", document);
var referenceId = "Bearer";
var reference = new OpenApiSecuritySchemeReference(referenceId, document);

document.Components ??= new();
document.Components.SecuritySchemes ??= new Dictionary<string, IOpenApiSecurityScheme>();
document.Components.SecuritySchemes[reference.Reference.Id] = scheme;
document.Components.SecuritySchemes ??= [];
document.Components.SecuritySchemes[referenceId] = scheme;
document.Security ??= [];
document.Security.Add(new() { [reference] = [] });

Expand Down
7 changes: 5 additions & 2 deletions src/TodoApp/OpenApi/ExamplesProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ private static void TryAddRequestExamples(
ApiDescription description,
IList<IOpenApiExampleMetadata> examples)
{
if (!body.Content.TryGetValue("application/json", out var mediaType) || mediaType.Example is not null)
if (body is null ||
body.Content is null ||
!body.Content.TryGetValue("application/json", out var mediaType) ||
mediaType.Example is not null)
{
return;
}
Expand Down Expand Up @@ -131,7 +134,7 @@ private static void TryAddResponseExamples(
foreach (var responseFormat in schemaResponse.ApiResponseFormats)
{
if (responses.TryGetValue(schemaResponse.StatusCode.ToString(CultureInfo.InvariantCulture), out var response) &&
response.Content.TryGetValue(responseFormat.MediaType, out var mediaType))
response.Content?.TryGetValue(responseFormat.MediaType, out var mediaType) is true)
{
mediaType.Example ??= (metadata ?? examples.SingleOrDefault((p) => p.SchemaType == schemaResponse.Type))?.GenerateExample(Context);
}
Expand Down
12 changes: 6 additions & 6 deletions src/TodoApp/TodoApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<TypeScriptToolsVersion>latest</TypeScriptToolsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0-preview.3.25172.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.0-preview.3.25171.6" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="10.0.0-preview.3.25172.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview.11" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0-preview.4.25258.110" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.0-preview.4.25258.110" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="10.0.0-preview.4.25258.110" PrivateAssets="all" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview.17" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.8.3" PrivateAssets="all" />
<PackageReference Include="NSwag.AspNetCore" Version="14.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.0-pr.3283.1282" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.0-pr.3283.1282" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.0-pr.3283.1370" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.0-pr.3283.1370" />
</ItemGroup>
<ItemGroup>
<Content Update="package.json;package-lock.json;tsconfig.json" CopyToPublishDirectory="Never" />
Expand Down
3 changes: 3 additions & 0 deletions tests/TodoApp.Tests/OpenApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public async Task Schema_Has_No_Validation_Warnings(string schemaUrl)
// Assert
var actual = await OpenApiDocument.LoadAsync(schema, "json", cancellationToken: TestContext.Current.CancellationToken);

Assert.NotNull(actual);
Assert.NotNull(actual.Diagnostic);
Assert.Empty(actual.Diagnostic.Errors);
Assert.NotNull(actual.Document);

var errors = actual.Document.Validate(ruleSet);

Expand Down
2 changes: 1 addition & 1 deletion tests/TodoApp.Tests/TodoApp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageReference Include="MartinCostello.Logging.XUnit.v3" Version="0.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0-preview.3.25172.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0-preview.4.25258.110" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="2.0.0-preview.11" />
<PackageReference Include="Microsoft.Playwright" Version="1.52.0" />
Expand Down