You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/tsp-client/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@
9
9
- Added `generate-lock-file` command, see [README](https://github.com/Azure/azure-sdk-tools/blob/main/tools/tsp-client/README.md) for more information.
10
10
- Removed the `--generate-lock-file` flag and replaced it with the command above.
11
11
- Migrated tsp-client from `node:util` to `yargs` for commandline infrastructure.
12
+
- Added `compare` command to compare a hand-authored Swagger to a TypeSpec-generated Swagger to understand the relevant differences between them.
Please note that these prerequisites apply on the repository where the client library is going to be generated. Repo owners should make sure to follow these prerequisites. Users working with a repository that already accepts this tool can continue to see the [Usage](#usage) section.
12
14
13
15
- Add an emitter-package.json to the repo following this [configuration](#emitter-packagejson).
14
16
- Add the [TempTypeSpecFiles](#TempTypeSpecFiles) directory to the .gitignore file for your repository.
15
17
16
18
## Usage
19
+
17
20
```
18
21
tsp-client <command> [options]
19
22
```
20
23
21
24
## Commands
25
+
22
26
Use one of the supported commands to get started generating clients from a TypeSpec project.
23
27
This tool will default to using your current working directory to generate clients in and will
24
28
use it to look for relevant configuration files. To specify a different output directory, use
25
29
the `-o` or `--output-dir` option.
26
30
27
31
### init
32
+
28
33
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.
29
34
30
35
The `init` command generates a directory structure following the standard pattern used across Azure SDK language repositories, creates a [tsp-location.yaml](#tsp-locationyaml) file to control generation, and performs an initial generation of the client library. If you want to skip client library generation, then pass the `--skip-sync-and-generate` flag.
31
36
32
37
> IMPORTANT: This command should be run from the root of the repository.
33
38
34
39
### update
40
+
35
41
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.
36
42
37
43
### sync
44
+
38
45
Sync a TypeSpec project with the parameters specified in tsp-location.yaml.
39
46
40
47
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.
41
48
42
49
### generate
50
+
43
51
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.
44
52
45
53
### convert
54
+
46
55
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.
47
56
57
+
### compare
58
+
59
+
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
60
+
correspond to differences in the service, allowing you to focus only on differences that are relevant.
61
+
48
62
### sort-swagger
63
+
49
64
Sort an existing swagger specification to be the same content order with TypeSpec generated swagger. This will allow you to easily compare and identify differences between the existing swagger and TypeSpec generated one. You should run this command on existing swagger files and check them in prior to creating converted TypeSpec PRs.
50
65
51
66
### generate-lock-file
52
67
53
68
Generate an emitter-package-lock.json under the eng/ directory based on existing `<repo-root>/eng/emitter-package.json`.
54
69
55
70
## Options
71
+
56
72
```
57
73
--arm Convert ARM swagger specification to TypeSpec [boolean]
58
74
-c, --tsp-config The tspconfig.yaml file to use [string]
@@ -65,9 +81,9 @@ Generate an emitter-package-lock.json under the eng/ directory based on existing
65
81
--save-inputs Don't clean up the temp directory after generation [boolean]
66
82
--skip-sync-and-generate Skip sync and generate during project init [boolean]
67
83
--swagger-readme Path or url to swagger readme file [string]
68
-
-o, --output-dir Specify an alternate output directory for the
84
+
-o, --output-dir Specify an alternate output directory for the
69
85
generated files. Default is your current directory [string]
70
-
--repo Repository where the project is defined for init
86
+
--repo Repository where the project is defined for init
71
87
or update [string]
72
88
-v, --version Show version number [boolean]
73
89
```
@@ -91,22 +107,23 @@ tsp-client update
91
107
## Important concepts
92
108
93
109
### Per project setup
110
+
94
111
Each project will need to have a configuration file called tsp-location.yaml that will tell the tool where to find the TypeSpec project.
95
112
96
113
#### tsp-location.yaml
97
114
98
-
This file is created through the `tsp-client init` command or you can manually create it under the project directory to run other commands supported by this tool.
115
+
This file is created through the `tsp-client init` command or you can manually create it under the project directory to run other commands supported by this tool.
99
116
100
117
> NOTE: This file should live under the project directory for each service.
101
118
102
119
The file has the following properties:
103
120
104
-
| Property | Description | IsRequired |
105
-
| --- | --- | --- |
106
-
| <aid="directory-anchor"></a> directory | The top level directory where the main.tsp for the service lives. This should be relative to the spec repo root such as `specification/cognitiveservices/OpenAI.Inference`| true |
107
-
| <aid="additionalDirectories-anchor"></a> additionalDirectories | Sometimes a typespec file will use a relative import that might not be under the main directory. In this case a single `directory` will not be enough to pull down all necessary files. To support this you can specify additional directories as a list to sync so that all needed files are synced. | false: default = null |
108
-
| <aid="commit-anchor"></a> commit | The commit sha for the version of the typespec files you want to generate off of. This allows us to have idempotence on generation until we opt into pointing at a later version. | true |
109
-
| <aid="repo-anchor"></a> repo | The repo this spec lives in. This should be either `Azure/azure-rest-api-specs` or `Azure/azure-rest-api-specs-pr`. Note that pr will work locally but not in CI until we add another change to handle token based auth. | true |
| <aid="directory-anchor"></a> directory | The top level directory where the main.tsp for the service lives. This should be relative to the spec repo root such as `specification/cognitiveservices/OpenAI.Inference`| true|
124
+
| <aid="additionalDirectories-anchor"></a> additionalDirectories | Sometimes a typespec file will use a relative import that might not be under the main directory. In this case a single `directory` will not be enough to pull down all necessary files. To support this you can specify additional directories as a list to sync so that all needed files are synced. | false: default = null |
125
+
| <aid="commit-anchor"></a> commit | The commit sha for the version of the typespec files you want to generate off of. This allows us to have idempotence on generation until we opt into pointing at a later version. | true|
126
+
| <aid="repo-anchor"></a> repo | The repo this spec lives in. This should be either `Azure/azure-rest-api-specs` or `Azure/azure-rest-api-specs-pr`. Note that pr will work locally but not in CI until we add another change to handle token based auth. | true|
110
127
111
128
Example:
112
129
@@ -135,7 +152,6 @@ See the following example of a valid tspconfig.yaml file: https://github.com/Azu
135
152
136
153
Using the tspconfig.yaml linked above, by default, the client libraries will be generated in the following directory for C#: `<repo>/sdk/contosowidgetmanager/Azure.Template.Contoso/`.
137
154
138
-
139
155
### emitter-package.json (Required)
140
156
141
157
`emitter-package.json`will be used the same as a `package.json` file. If the is no `emitter-package-lock.json` file, the tool will run `npm install` on the contents of `emitter-package.json`. This file allows each repository to pin the version of their emitter and other dependencies to be used when generating client libraries.
0 commit comments