Skip to content

Commit 4b11314

Browse files
committed
add csharp sample
1 parent 9787ee3 commit 4b11314

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

samples/csharp/Program.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.ClientModel;
2+
using Todo;
3+
using Todo.Models;
4+
5+
TodoClient client = new TodoClient(new Uri("http://localhost:3000"), new KeyCredential("token"), new TodoClientOptions());
6+
TodoItems itemsClient = client.GetItemsClient();
7+
8+
Result<TodoItem> result = await itemsClient.CreateAsync(
9+
item: new TodoItem("title", TodoItemStatus.NotStarted)
10+
{
11+
Labels = BinaryData.FromObjectAsJson(new string[] { "label1", "label2" })
12+
}
13+
);
14+
15+
if (result.Value != null)
16+
{
17+
Console.WriteLine($"Created item with id: {result.Value.Id}");
18+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>csharp_client_app</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<ProjectReference Include="..\..\tsp-output\csharp\src\Todo.csproj" />
12+
</ItemGroup>
13+
</Project>

src/server.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import fastifyReference from "@scalar/fastify-api-reference";
77
import { Service } from "./service.js";
88
const localFile = (fileName: string) =>
99
new URL(fileName, import.meta.url).pathname;
10-
1110
const serviceHandlers = new Service();
1211
const pluginOptions = {
13-
specification: localFile("../tsp-output/@typespec/openapi3/openapi.yaml"),
12+
specification: "./tsp-output/@typespec/openapi3/openapi.yaml",
1413
serviceHandlers,
1514
};
1615

0 commit comments

Comments
 (0)