@typespec/http-client-csharp 0.1.9-alpha.20240715.3 → 0.1.9-alpha.20240716.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generator/Microsoft.Generator.CSharp.ClientModel.dll +0 -0
- package/dist/generator/Microsoft.Generator.CSharp.ClientModel.pdb +0 -0
- package/dist/generator/Microsoft.Generator.CSharp.Customization.dll +0 -0
- package/dist/generator/Microsoft.Generator.CSharp.Customization.pdb +0 -0
- package/dist/generator/Microsoft.Generator.CSharp.Input.dll +0 -0
- package/dist/generator/Microsoft.Generator.CSharp.Input.pdb +0 -0
- package/dist/generator/Microsoft.Generator.CSharp.dll +0 -0
- package/dist/generator/Microsoft.Generator.CSharp.pdb +0 -0
- package/package.json +1 -1
- package/readme.md +66 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-csharp",
|
|
3
|
-
"version": "0.1.9-alpha.
|
|
3
|
+
"version": "0.1.9-alpha.20240716.6",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "The typespec library that can be used to generate C# models from a TypeSpec REST protocol binding",
|
|
6
6
|
"homepage": "https://github.com/Microsoft/typespec",
|
package/readme.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# TypeSpec csharp emitter library
|
|
2
|
+
|
|
3
|
+
This is a TypeSpec library that will emit a .NET SDK from TypeSpec.
|
|
4
|
+
|
|
5
|
+
## Prerequisite
|
|
6
|
+
|
|
7
|
+
Install [Node.js](https://nodejs.org/download/) 16 or above. (Verify by `node --version`)
|
|
8
|
+
Install [**.NET 8.0 SDK**](https://dotnet.microsoft.com/download/dotnet/8.0) for your specific platform. (or a higher version)
|
|
9
|
+
|
|
10
|
+
## Getting started
|
|
11
|
+
|
|
12
|
+
### Initialize TypeSpec Project
|
|
13
|
+
|
|
14
|
+
Follow [TypeSpec Getting Started](https://github.com/microsoft/typespec/#using-node--npm) to initialize your TypeSpec project.
|
|
15
|
+
|
|
16
|
+
Make sure `npx tsp compile .` runs correctly.
|
|
17
|
+
|
|
18
|
+
### Add typespec csharp
|
|
19
|
+
|
|
20
|
+
Run `npm install @typespec/http-client-csharp`.
|
|
21
|
+
|
|
22
|
+
### Generate .NET client
|
|
23
|
+
|
|
24
|
+
Run command `npx tsp compile --emit @typespec/http-client-csharp <path-to-typespec-file>`
|
|
25
|
+
|
|
26
|
+
e.g.
|
|
27
|
+
|
|
28
|
+
```cmd
|
|
29
|
+
npx tsp compile main.tsp --emit @typespec/http-client-csharp
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
You can further configure the SDK generated, using the emitter options on @typespec/http-client-csharp.
|
|
35
|
+
|
|
36
|
+
You can set options in the command line directly via `--option @typespec/http-client-csharp.<optionName>=XXX`, e.g. `--option @typespec/http-client-csharp.namespace=MyService.Namespace`
|
|
37
|
+
|
|
38
|
+
or
|
|
39
|
+
|
|
40
|
+
Modify `tspconfig.yaml` in typespec project, add emitter options under options/@typespec/http-client-csharp.
|
|
41
|
+
|
|
42
|
+
```diff
|
|
43
|
+
emit:
|
|
44
|
+
- "@typespec/http-client-csharp"
|
|
45
|
+
options:
|
|
46
|
+
"@typespec/http-client-csharp":
|
|
47
|
+
+ namespace: MyService.Namespace
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Supported Emitter options**:
|
|
51
|
+
|
|
52
|
+
- `namespace` define the client library namespace. e.g. MyService.Namespace.
|
|
53
|
+
- `emitter-output-dir` define the output dire path which will store the generated code.
|
|
54
|
+
- `generate-protocol-methods` indicate if you want to generate **protocol method** for every operation or not. The default value is true.
|
|
55
|
+
- `generate-convenience-methods` indicate if you want to generate **convenience method** for every operation or not. The default value is true.
|
|
56
|
+
- `unreferenced-types-handling` define the strategy how to handle the unreferenced types. It can be `removeOrInternalize`, `internalize` or `keepAll`
|
|
57
|
+
- `model-namespace` indicate if we want to put the models in their own namespace which is a sub namespace of the client library namespace plus ".Models". if it is set `false`, the models will be put in the same namespace of the client. The default value is `true`.
|
|
58
|
+
- `clear-output-folder` indicate if you want to clear up the output folder.
|
|
59
|
+
- `package-name` define the package name.
|
|
60
|
+
|
|
61
|
+
## Convenience API
|
|
62
|
+
|
|
63
|
+
By default, TypeSpec csharp generates all protocol APIs and convenience APIs.
|
|
64
|
+
A few exceptions are API of JSON Merge Patch, and API of long-running operation with ambiguous response type.
|
|
65
|
+
|
|
66
|
+
You can configure whether generate convenience API or not via `convenienceAPI` decorator.
|