Skip to content

Commit 4263c77

Browse files
committed
Update kiota and docs
1 parent 06aedf1 commit 4263c77

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

.config/dotnet-tools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"rollForward": false
3232
},
3333
"microsoft.openapi.kiota": {
34-
"version": "1.22.3",
34+
"version": "1.23.0",
3535
"commands": [
3636
"kiota"
3737
],

docs/usage/openapi-client.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The following code generators are supported, though you may try others as well:
1212

1313
# [NSwag](#tab/nswag)
1414

15-
For C# clients, we provide an additional package that provides workarounds for bugs in NSwag and enables using partial PATCH/POST requests.
15+
For C# clients, we provide an additional package that provides workarounds for bugs in NSwag and enables using partial POST/PATCH requests.
1616

1717
To add it to your project, run the following command:
1818
```
@@ -146,16 +146,36 @@ From here, continue from step 3 in the list of steps for Visual Studio.
146146

147147
# [Kiota](#tab/kiota)
148148

149-
To generate your C# client, install the Kiota tool by following the steps at https://learn.microsoft.com/en-us/openapi/kiota/install#install-as-net-tool.
150-
151-
Next, generate client code by running the [command line tool](https://learn.microsoft.com/en-us/openapi/kiota/using#client-generation). For example:
149+
To generate your C# client, first add the Kiota tool to your solution:
152150

153151
```
154-
dotnet kiota generate --language CSharp --class-name ExampleApiClient --output ./GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --openapi http://localhost:14140/swagger/v1/swagger.json
152+
dotnet tool install microsoft.openapi.kiota
153+
```
154+
155+
After adding the `JsonApiDotNetCore.OpenApi.Client.Kiota` package to your project, add a `KiotaReference` element
156+
to your project file to import your OpenAPI file. For example:
157+
158+
```xml
159+
<Project Sdk="Microsoft.NET.Sdk">
160+
<ItemGroup>
161+
<KiotaReference Include="path/to/openapi.json">
162+
<NamespaceName>$(MSBuildProjectName).GeneratedCode</NamespaceName>
163+
<ClassName>ExampleApiClient</ClassName>
164+
<OutputPath>./GeneratedCode</OutputPath>
165+
<ExtraArguments>$(JsonApiExtraArguments)</ExtraArguments>
166+
</KiotaReference>
167+
</ItemGroup>
168+
</Project>
155169
```
156170

171+
> [!NOTE]
172+
> The `ExtraArguments` parameter is required for compatibility with JSON:API.
173+
174+
Next, build your project. It runs the kiota command-line tool, which generates files in the `GeneratedCode` subdirectory.
175+
157176
> [!CAUTION]
158-
> The `--backing-store` switch is needed for JSON:API partial PATCH/POST requests to work correctly.
177+
> If you're not using `<KiotaReference>`, at least make sure you're passing the `--backing-store` switch to the command-line tool,
178+
> which is needed for JSON:API partial POST/PATCH requests to work correctly.
159179
160180
Kiota is pretty young and therefore still rough around the edges. At the time of writing, there are various bugs, for which we have workarounds
161181
in place. For a full example, see the [example project](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/openapi/src/Examples/OpenApiKiotaClientExample).

0 commit comments

Comments
 (0)