Repository navigation
Description
Describe the bug
Hi I am using ASP.NET Core Minimal API Serverless Application
this is my current .csproj ,
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Generate ready to run images during publishing to improvement cold starts. -->
<PublishReadyToRun>true</PublishReadyToRun>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>0</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningLevel>0</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.3.1" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.2" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.3.77" />
<PackageReference Include="AWSSDK.SQS" Version="3.7.2.74" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="StackExchange.Redis" Version="2.6.48" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.3" />
</ItemGroup>
</Project>
I have just added Swashbuckle.AspNetCore.Filters for adding request examples for the swagger page ,
now i am not able to load swagger page it shows internal server error
The error that is logged in cloudwatch :
System.TypeLoadException: Could not load type 'Swashbuckle.AspNetCore.Filters.IMultipleExamplesProvider`1' from assembly 'Swashbuckle.AspNetCore.Filters, Version=7.0.3.0,
the page is working fine in local , and if i don't use the 'Swashbuckle.AspNetCore.Filters' the lambda is working fine
Expected Behavior
The swagger page should work with Swashbuckle.AspNetCore.Filters package dependency
Current Behavior
The error that is logged in cloudwatch :
System.TypeLoadException: Could not load type 'Swashbuckle.AspNetCore.Filters.IMultipleExamplesProvider`1' from assembly 'Swashbuckle.AspNetCore.Filters, Version=7.0.3.0,
Reproduction Steps
public class Personrequest: IMultipleExamplesProvider<StockImageRequest>
{
public IEnumerable<SwaggerExample<person>> GetExamples()
{
yield return SwaggerExample.Create(
"Mandatory images",
new person { name="xyz"}
);
}
}
System.TypeLoadException: Could not load type 'Swashbuckle.AspNetCore.Filters.IMultipleExamplesProvider`
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.3.1" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.2" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.3.77" />
<PackageReference Include="AWSSDK.SQS" Version="3.7.2.74" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.6">
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="StackExchange.Redis" Version="2.6.48" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.3" />
Targeted .NET Platform
.NET6
Operating System and version
Amazon Linux
Activity
ashishdhingra commentedon Jul 8, 2022
Hi @noopd13,
Good afternoon.
Could you please share the minimal code solution to reproduce the issue? Also, was it working earlier in Lambda environment before you upgraded minimal API?
Thanks,
Ashish
noopd13 commentedon Jul 11, 2022
Hi @ashishdhingra , have added my solution code . have developed these API's based on .net 6 minimal api , was never upgraded to minimal api , it was working fine in lambda environment until i added aspnetcore.filters dependency in the code
Program.cs
PersonRequestExample.cs
ashishdhingra commentedon Jul 11, 2022
@noopd13 Thanks for sharing the example. Unfortunately, I'm unable to reproduce the issue using ASP.NET Core Minimal API serverless application template. Below is the example code and output.
.csproj
Program.cs
PersonRequestExample.cs
Controllers\PersonController.cs
Invoking the URL

https://XXXXXXXX.execute-api.us-east-2.amazonaws.com/Prod/swagger/index.htmlsuccessfully displays the below Swagger UI:No error is logged in CloudWatch logs.
(I'm unsure if your
PersonRequestExampleis correct. I followed an example available online)References:
Thanks,
Ashish
noopd13 commentedon Jul 12, 2022
hi @ashishdhingra , i have used the filter examples as a part of request
noopd13 commentedon Jul 12, 2022
hI @ashishdhingra , adding the reference of Microsoft.OpenApi fixed the issue thanks
github-actions commentedon Jul 12, 2022
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.