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: README.md
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,12 @@ against the one generated from TypeSpec to determine if the TypeSpec accurately
28
28
containing them. If the paths are folders, the tool will search for all Swagger files in that folder,
29
29
but will not search subfolders.
30
30
31
+
`lhs_root` and `rhs_root` are optional parameters. If you are pointing to Swagger files, they should not be needed. However, if you are compiling
32
+
TypeSpec, you should provide this so that the references get generated and resolve correctly. The value should be to set to where the Swagger
33
+
files should be generated. Since that would normally result in overwriting the existing files, it's recommended that you just replace the path
34
+
segment "stable" or "preview" with "generated" in the path. In this way, the Swagger will be generated into a unique folder with the same relative
35
+
references as if it had been generated in the "correct" folder. This allows the tool to resolve the references correctly.
36
+
31
37
### Options
32
38
33
39
-`--compile-tsp`: The tool will attempt to compile TypeSpec files to Swagger using the
@@ -51,6 +57,10 @@ but will not search subfolders.
51
57
these, for example to compare the definitions themselves between two Swaggers, provide this flag.
52
58
-`--flatten-paths`: The default format of paths in the output is an array of path segments. If you prefer
53
59
to flatten these into a forward-slash delimited string, provide this flag.
60
+
-`--lhs-root`: The root path for the left-hand side Swagger files. This is used to resolve references
61
+
when compiling TypeSpec files. If omitted, the tool will attempt to resolve the references without it.
62
+
-`--rhs-root`: The root path for the right-hand side Swagger files. This is used to resolve references
63
+
when compiling TypeSpec files. If omitted, the tool will attempt to resolve the references without it.
54
64
55
65
### .env File
56
66
@@ -111,7 +121,9 @@ These steps assumed that `--lhs` points to a Swagger folder and `--rhs` points t
111
121
1. Ensure you have updated the dependencies in your fork by running `npm install` in the REST API specs repo root. You may need to delete `package-lock.json` first. Copy the path to the `node_modules/@typespec/compiler` package.
112
122
2. Set the `TYPESPEC_COMPILER_PATH` environment variable (ideally in .env) to the path you copied in step 1.
113
123
3. Ensure that LHS and RHS point to the appropriate paths in the REST API specs repo.
114
-
4. If you are comparing to a multi-versioned TypeSpec, you should probably include the `TYPESPEC_VERSION_SELECTOR` environment variable to ensure you are generating the right version for comparison.
124
+
4. By convention, if you are comparing hand-written Swagger to TypeSpec, the Swagger should be LHS and the TypeSpec should be RHS. When compiling TypeSpec, you will
125
+
need to set RHS_ROOT. It will generally be the same path as LHS, but with the "stable" or "preview" segment replaced with "generated".
126
+
5. If you are comparing to a multi-versioned TypeSpec, you should probably include the `TYPESPEC_VERSION_SELECTOR` environment variable to ensure you are generating the right version for comparison.
0 commit comments