[csharp][generichost] Verify net9 samples up to date (#21637)

* verify net9 samples up to date

* verify net9 samples up to date

* remove erroneous files

* use different logic to delete directories
This commit is contained in:
devhl-labs
2025-07-27 22:56:24 -04:00
committed by GitHub
parent ef22749345
commit dfc66e34aa
3 changed files with 13 additions and 106 deletions

View File

@@ -142,37 +142,19 @@ jobs:
path: modules/openapi-generator-cli/target
- name: Delete samples that are entirely generated
run: |
rm -rf samples/client/petstore/csharp/generichost/latest/HelloWorld
rm -rf samples/client/petstore/csharp/generichost/latest/Tags
rm -rf samples/client/petstore/csharp/generichost/latest/OneOfList
rm -rf samples/client/petstore/csharp/generichost/net8/AllOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net8/FormModels
rm -rf samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
rm -rf samples/client/petstore/csharp/generichost/net8/OneOf
rm -rf samples/client/petstore/csharp/generichost/net8/Petstore
rm -rf samples/client/petstore/csharp/generichost/net8/SourceGeneration
rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
rm -rf samples/client/petstore/csharp/generichost/standard2.0/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.8/AllOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net4.8/FormModels
rm -rf samples/client/petstore/csharp/generichost/net4.8/OneOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate
rm -rf samples/client/petstore/csharp/generichost/net4.7/AllOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net4.7/FormModels
rm -rf samples/client/petstore/csharp/generichost/net4.7/OneOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate
# List all directories in generichost, filter out Manual directories, and remove the rest
cd samples/client/petstore/csharp/generichost
for version_dir in */ ; do
if [ -d "$version_dir" ]; then
cd "$version_dir"
for dir in */ ; do
if [ -d "$dir" ] && [[ ! "$dir" =~ Manual ]]; then
rm -rf "$dir"
fi
done
cd ..
fi
done
- name: Generate samples
run: |
bash bin/generate-samples.sh

View File

@@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Org.OpenAPITools\Org.OpenAPITools.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,61 +0,0 @@
//namespace ConsoleApp1
//{
// internal class Program
// {
// static void Main(string[] args)
// {
// Console.WriteLine("Hello, World!");
// }
// }
//}
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Extensions;
namespace YourProject
{
public class Program
{
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
var api = host.Services.GetRequiredService<IAnotherFakeApi>();
ICall123TestSpecialTagsApiResponse apiResponse = await api.Call123TestSpecialTagsAsync("todo");
ModelClient? model = apiResponse.Ok();
}
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
.ConfigureApi((context, services, options) =>
{
// The type of token here depends on the api security specifications
// Available token types are ApiKeyToken, BasicToken, BearerToken, HttpSigningToken, and OAuthToken.
BearerToken token = new("<your token>");
options.AddTokens(token);
// optionally choose the method the tokens will be provided with, default is RateLimitProvider
options.UseProvider<RateLimitProvider<BearerToken>, BearerToken>();
options.ConfigureJsonOptions((jsonOptions) =>
{
// your custom converters if any
});
options.AddApiHttpClients(client =>
{
// client configuration
}, builder =>
{
builder
.AddRetryPolicy(2)
.AddTimeoutPolicy(TimeSpan.FromSeconds(5))
.AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30));
// add whatever middleware you prefer
}
);
});
}
}