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
12 changes: 12 additions & 0 deletions docs/guide/http/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,15 @@ public class ValidatedCompoundEndpoint2
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Http/WolverineWebApi/Validation/ValidatedCompoundEndpoint.cs#L33-L61' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_optional_iresult_with_openapi_metadata' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## With Microsoft.Extensions.ApiDescription.Server

Just a heads up, if you are trying to use [Microsoft.Extensions.ApiDescription.Server](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/aspnetcore-openapi?view=aspnetcore-9.0&tabs=net-cli%2Cvisual-studio-code#generate-openapi-documents-at-build-time) and
you get an `ObjectDisposedException` error on compilation against the `IServiceProvider`, follow these steps to fix:

1. Remove `Microsoft.Extensions.ApiDescription.Server` altogether
2. Just run `dotnet run` to see why your application isn't able to start correctly, and fix *that* problem
3. Add `Microsoft.Extensions.ApiDescription.Server` back

For whatever reason, the source generator for OpenAPI tries to start the entire application, including Wolverine's
`IHostedService`, and the whole thing blows up with that very unhelpful message if anything is wrong with the application.
46 changes: 46 additions & 0 deletions src/Transports/AWS/WebAppWithSQS/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using JasperFx;
using Wolverine;
using Wolverine.AmazonSqs;
using Wolverine.Http;
using Wolverine.RabbitMQ;
using Wolverine.Transports.Tcp;
using Wolverine.Util;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();

builder.Services.AddWolverineHttp();

builder.Host.UseWolverine(opts =>
{
opts.UseAmazonSqsTransportLocally().AutoProvision();

opts.PublishMessage<ExtLog>().ToSqsQueue("ext-logs");

opts.UseRabbitMq().AutoProvision();

opts.ListenAtPort(PortFinder.GetAvailablePort());

opts.ListenToRabbitQueue("foo");
});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}

app.UseHttpsRedirection();

app.MapWolverineEndpoints();


return await app.RunJasperFxCommands(args);

public record ExtLog;

23 changes: 23 additions & 0 deletions src/Transports/AWS/WebAppWithSQS/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5065",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7261;http://localhost:5065",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
23 changes: 23 additions & 0 deletions src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Http\Wolverine.Http\Wolverine.Http.csproj" />
<ProjectReference Include="..\..\RabbitMQ\Wolverine.RabbitMQ\Wolverine.RabbitMQ.csproj" />
<ProjectReference Include="..\Wolverine.AmazonSqs\Wolverine.AmazonSqs.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@WebAppWithSQS_HostAddress = http://localhost:5065

GET {{WebAppWithSQS_HostAddress}}/weatherforecast/
Accept: application/json

###
8 changes: 8 additions & 0 deletions src/Transports/AWS/WebAppWithSQS/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions src/Transports/AWS/WebAppWithSQS/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
7 changes: 7 additions & 0 deletions wolverine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiTenantedEfCoreWithPost
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiTenantedEfCoreWithSqlServer", "src\Persistence\MultiTenantedEfCoreWithSqlServer\MultiTenantedEfCoreWithSqlServer.csproj", "{F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAppWithSQS", "src\Transports\AWS\WebAppWithSQS\WebAppWithSQS.csproj", "{692321C4-1A3A-4603-A42F-36B86DC784DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -712,6 +714,10 @@ Global
{F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}.Release|Any CPU.Build.0 = Release|Any CPU
{692321C4-1A3A-4603-A42F-36B86DC784DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{692321C4-1A3A-4603-A42F-36B86DC784DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692321C4-1A3A-4603-A42F-36B86DC784DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692321C4-1A3A-4603-A42F-36B86DC784DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{24497E6A-D6B1-4C80-ABFB-57FFAD5070C4} = {96119B5E-B5F0-400A-9580-B342EBE26212}
Expand Down Expand Up @@ -837,5 +843,6 @@ Global
{3E83F8CE-A04A-477E-A103-1AC7CFDEBF0D} = {7A9E0EAE-9ABF-40F6-9DB9-8FB1243F4210}
{11C936B6-A659-4CF3-851D-FFB339B351FA} = {7A9E0EAE-9ABF-40F6-9DB9-8FB1243F4210}
{F96DEAFA-C73E-4AF1-A858-E95E9EDB119F} = {7A9E0EAE-9ABF-40F6-9DB9-8FB1243F4210}
{692321C4-1A3A-4603-A42F-36B86DC784DA} = {ABE5F332-6709-4EDF-B88A-39DB96542B18}
EndGlobalSection
EndGlobal
Loading