Skip to content

Commit 38869c3

Browse files
[tsp-client] README updates (#9691)
* update readme * add override docs * add help info * update examples * use contoso project in example * rewording * add example --------- Co-authored-by: catalinaperalta <[email protected]>
1 parent 213127f commit 38869c3

1 file changed

Lines changed: 69 additions & 28 deletions

File tree

tools/tsp-client/README.md

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,29 @@ tsp-client <command> [options]
2424
## Commands
2525

2626
Use one of the supported commands to get started generating clients from a TypeSpec project.
27+
2728
This tool will default to using your current working directory to generate clients in and will
2829
use it to look for relevant configuration files. To specify a different output directory, use
2930
the `-o` or `--output-dir` option.
3031

32+
To see supported commands, run:
33+
34+
```
35+
tsp-client --help
36+
```
37+
38+
To see supported parameters and options for a specific command, run:
39+
40+
```
41+
tsp-client <command> --help
42+
```
43+
44+
Example using the `init` command:
45+
46+
```
47+
tsp-client init --help
48+
```
49+
3150
### init
3251

3352
Initialize the client library directory using a tspconfig.yaml. When running this command pass in a path to a local or remote tspconfig.yaml with the `-c` or `--tsp-config` flag.
@@ -36,24 +55,54 @@ The `init` command generates a directory structure following the standard patter
3655

3756
> IMPORTANT: This command should be run from the root of the repository.
3857
58+
Example:
59+
60+
```
61+
tsp-client init -c https://github.com/Azure/azure-rest-api-specs/blob/dee71463cbde1d416c47cf544e34f7966a94ddcb/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml
62+
```
63+
3964
### update
4065

4166
Sync and generate client libraries from a TypeSpec project. The `update` command will look for a [tsp-location.yaml](#tsp-locationyaml) file in your current directory to sync a TypeSpec project and generate a client library.
4267

68+
Example:
69+
70+
```
71+
tsp-client update
72+
```
73+
4374
### sync
4475

4576
Sync a TypeSpec project with the parameters specified in tsp-location.yaml.
4677

4778
By default the `sync` command will look for a tsp-location.yaml to get the project details and sync them to a temporary directory called `TempTypeSpecFiles`. Alternately, you can pass in the `--local-spec-repo` flag with the path to your local TypeSpec project to pull those files into your temporary directory.
4879

80+
Example:
81+
82+
```
83+
tsp-client sync
84+
```
85+
4986
### generate
5087

5188
Generate a client library from a TypeSpec project. The `generate` command should be run after the `sync` command. `generate` relies on the existence of the `TempTypeSpecFiles` directory created by the `sync` command and on an `emitter-package.json` file checked into your repository at the following path: `<repo root>/eng/emitter-package.json`. The `emitter-package.json` file is used to install project dependencies and get the appropriate emitter package.
5289

90+
Example:
91+
92+
```
93+
tsp-client generate
94+
```
95+
5396
### convert
5497

5598
Convert an existing swagger specification to a TypeSpec project. This command should only be run once to get started working on a TypeSpec project. TypeSpec projects will need to be optimized manually and fully reviewed after conversion. When using this command a path or url to a swagger README file is required through the `--swagger-readme` flag. By default, the converted TypeSpec project will leverage TypeSpec built-in libraries with standard patterns and templates (highly recommended), which will cause discrepancies between the generated TypeSpec and original swagger. If you really don't want this intended discrepancy, add `--fully-compatible` flag to generate a TypeSpec project that is fully compatible with the swagger.
5699

100+
Example:
101+
102+
```
103+
tsp-client convert --swagger-readme <path to swagger README file>/readme.md
104+
```
105+
57106
### compare
58107

59108
Compares two Swagger definitions to identify the relevant differences between them. This command is useful when comparing an existing Swagger definition with a TypeSpec generated one. The `compare` command requires two parameters: `--lhs` which will typically be the original hand-authored Swagger and `--rhs` which will usually be the folder containing your TypeSpec. The command will generate the Swagger and compare the two definitions. The command will ignore differences in the Swagger that don't
@@ -72,48 +121,40 @@ This command generates the default configuration files used by tsp-client. Run t
72121
Example:
73122

74123
```
75-
azure-sdk-for-python> tsp-client generate-config-files --package-json <path to @azure-tools/typespec-python emitter clone>\package.json
124+
tsp-client generate-config-files --package-json <path to emitter repo clone>/package.json
76125
```
77126

78-
### generate-lock-file
79-
80-
Generate an emitter-package-lock.json under the eng/ directory based on existing `<repo-root>/eng/emitter-package.json`.
81-
82-
## Options
127+
Example using the `azure-sdk-for-js` and the `@azure-tools/typespec-ts` emitter:
83128

84129
```
85-
--arm Convert ARM swagger specification to TypeSpec [boolean]
86-
-c, --tsp-config The tspconfig.yaml file to use [string]
87-
--commit Commit to be used for project init or update [string]
88-
-d, --debug Enable debug logging [boolean]
89-
--emitter-options The options to pass to the emitter [string]
90-
-h, --help Show help [boolean]
91-
--local-spec-repo Path to local repository with the TypeSpec project [string]
92-
--no-prompt Skip prompting for output directory confirmation [boolean]
93-
--save-inputs Don't clean up the temp directory after generation [boolean]
94-
--skip-sync-and-generate Skip sync and generate during project init [boolean]
95-
--swagger-readme Path or url to swagger readme file [string]
96-
-o, --output-dir Specify an alternate output directory for the
97-
generated files. Default is your current directory [string]
98-
--repo Repository where the project is defined for init
99-
or update [string]
100-
-v, --version Show version number [boolean]
130+
azure-sdk-for-js> tsp-client generate-config-files --package-json <relative or absolute path to repo clone of @azure-tools/typespec-ts package>/package.json
101131
```
102132

103-
## Examples
133+
If you need to override dependencies for your emitter-package.json you can create a json file to explicitly list the package and corresponding version you want to override. This will add an `overrides` section in your emitter-package.json that will be used during `npm install` or `npm ci`. [See npm overrides doc.](https://docs.npmjs.com/cli/v10/configuring-npm/package-json?v=true#overrides)
104134

105-
Initializing and generating a new client from a `tspconfig.yaml`:
135+
Example json file with package overrides:
136+
137+
```
138+
{
139+
"@azure-tools/typespec-python": "0.36.0",
140+
"@typespec/compiler": "0.61.0"
141+
}
142+
```
106143

107-
> NOTE: The `init` command must be run from the root of the repository.
144+
Example command specifying overrides:
108145

109146
```
110-
tsp-client init -c https://github.com/Azure/azure-rest-api-specs/blob/3bae4e510063fbd777b88ea5eee03c41644bc9da/specification/cognitiveservices/ContentSafety/tspconfig.yaml
147+
tsp-client generate-config-files --package-json <path to emitter repo clone>/package.json --overrides <path to overrides file>.json
111148
```
112149

113-
Generating in a directory that contains a `tsp-location.yaml`:
150+
### generate-lock-file
151+
152+
Generate an emitter-package-lock.json under the eng/ directory based on existing `<repo-root>/eng/emitter-package.json`.
153+
154+
Example:
114155

115156
```
116-
tsp-client update
157+
tsp-client generate-lock-file
117158
```
118159

119160
## Important concepts

0 commit comments

Comments
 (0)