kiota/specs/cli/client-edit.md

115 строки
5.1 KiB
Markdown
Исходник Постоянная ссылка Обычный вид История

2023-12-06 23:15:24 +03:00
# kiota client edit
## Description
`kiota client update` allows a developer to edit an existing API client int the `workspace.json` file. If either the `workspace.json` file or if the `--client-name` client can't be found within the `workspace.json` file, the command should error out and let the developer know.
2023-12-06 23:15:24 +03:00
When executing, the API entry defined by the `--client-name` parameter will be modified. All parameters should be supported and the only required one is `--client-name`. All others are optional as they would only modify the configuration of the API client. If the OpenAPI description location changed or any properties of the client entry in `workspace.json`, a new hash composed of the Kiota version, the OpenAPI description location and the properties of the client will be generated and and would trigger an update to the [API Manifest](https://www.ietf.org/archive/id/draft-miller-api-manifest-01.html).
2023-12-06 23:15:24 +03:00
Once the `workspace.json` file and the API Manifest are updated, the code generation will be executed based on the newly updated API client configuration.
2023-12-06 23:15:24 +03:00
## Parameters
2024-01-26 20:31:53 +03:00
| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
2024-01-26 20:31:53 +03:00
| `--client-name \| --cn` | Yes | graphDelegated | Name of the client. Unique within the parent API. If not provided, defaults to --class-name or its default. | Yes, without its value |
| `--openapi \| -d` | No | https://aka.ms/graph/v1.0/openapi.yaml | The location of the OpenAPI description in JSON or YAML format to use to generate the SDK. Accepts a URL or a local path. | Yes, without its value |
| `--include-path \| -i` | No | /me/chats#GET | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. | Yes, without its value |
| `--exclude-path \| -e` | No | \*\*/users/\*\* | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. | Yes, without its value |
| `--language \| -l` | No | csharp | The target language for the generated code files or for the information. | Yes |
| `--namespace-name \| -n` | No | Contoso.GraphApp | The namespace of the client class. Defaults to `Microsoft.Graph`. | Yes, without its value |
2024-03-04 19:35:17 +03:00
| `--backing-store \| -b` | No | | Defaults to `false` | Yes |
2024-01-26 20:31:53 +03:00
| `--exclude-backward-compatible \| --ebc` | No | | Whether to exclude the code generated only for backward compatibility reasons or not. Defaults to `false`. | Yes |
| `--structured-media-types \| -m` | No | `application/json` |Any valid media type which will match a request body type or a response type in the OpenAPI description. Default are documented [here](https://learn.microsoft.com/en-us/openapi/kiota/using#--structured-mime-types--m). | Yes |
| `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. | Yes |
2024-03-04 19:35:17 +03:00
| `--output \| -o` | No | ./generated/graph/csharp | The output directory or file path for the generated code files. Defaults to `./output`. | Yes, without its value |
2023-12-06 23:15:24 +03:00
> [!NOTE]
> It is not required to use the CLI to edit clients. It is possible to edit a client by modifying its entry in the `clients` section of the `workspace.json` file. See the [workspace.json schema](../schemas/workspace.json) for more information.
2023-12-06 23:15:24 +03:00
## Using `kiota client edit`
```bash
kiota client edit --client-name "GraphClient" --exclude-path "/users/$count"
2023-12-06 23:15:24 +03:00
```
_The resulting `workspace.json` file will look like this:_
2023-12-06 23:15:24 +03:00
2023-12-07 22:23:26 +03:00
```jsonc
2023-12-06 23:15:24 +03:00
{
"version": "1.0.0",
"clients": {
"GraphClient": {
"descriptionLocation": "https://aka.ms/graph/v1.0/openapi.yaml",
2023-12-06 23:15:24 +03:00
"includePatterns": ["**/users/**"],
2023-12-08 21:03:23 +03:00
"excludePatterns": ["/users/$count"],
2023-12-06 23:15:24 +03:00
"language": "csharp",
"outputPath": "./generated/graph/csharp",
"clientNamespaceName": "Contoso.GraphApp",
2024-01-10 23:37:21 +03:00
"structuredMediaTypes": [
"application/json"
],
"usesBackingStore": true,
"includeAdditionalData": true
2023-12-06 23:15:24 +03:00
}
}
}
```
_The resulting `apimanifest.json` file will look like this:_
2023-12-07 22:23:26 +03:00
```jsonc
2023-12-06 23:15:24 +03:00
{
"publisher": {
"name": "Microsoft Graph",
"contactEmail": "graphsdkpub@microsoft.com"
},
"apiDependencies": {
"GraphClient": {
"x-ms-kiotaHash": "9EDF8506CB74FE44...",
"apiDescriptionUrl": "https://aka.ms/graph/v1.0/openapi.yaml",
2023-12-06 23:15:24 +03:00
"apiDeploymentBaseUrl": "https://graph.microsoft.com",
"apiDescriptionVersion": "v1.0",
"requests": [
{
"method": "GET",
"uriTemplate": "/users"
},
{
"method": "POST",
"uriTemplate": "/users"
},
{
"method": "GET",
"uriTemplate": "/users/{user-id}"
},
{
"method": "PATCH",
"uriTemplate": "/users/{user-id}"
},
{
"method": "DELETE",
"uriTemplate": "/users/{user-id}"
}
]
}
}
}
```
## File structure
```bash
/
└─.kiota
└─apimanifest.json
└─workspace.json
└─documents
└─GraphClient
2024-05-13 15:40:37 +03:00
└─openapi.yaml
2023-12-06 23:15:24 +03:00
└─generated
└─graph
└─csharp
└─... # Generated code files
└─GraphClient.cs
```