Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ To regenerate a specific integration test client (faster than regenerating all):

```bash
cd packages/typespec-ts
npx tsx ./test/commands/gen-cadl-ranch.js --tag=azure-modular --filter=payload/xml
npx tsx ./test/commands/gen-spector.js --tag=azure-modular --filter=payload/xml
```

Replace `payload/xml` with the path of the specific test you want to regenerate.
Expand Down
16 changes: 8 additions & 8 deletions .github/skills/spector-test-implementer/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Read `temp/specs/<path>/mockapi.ts`. Extract all scenario names (the `Scenarios.

### Step 3: Check Existing Implementation

Check whether the path already exists in the `azureModularTsps` array in `test/commands/cadl-ranch-list.js`, and whether a `.spec.ts` file already exists in `test/azureModularIntegration/`.
Check whether the path already exists in the `azureModularTsps` array in `test/commands/spector-list.js`, and whether a `.spec.ts` file already exists in `test/azureModularIntegration/`.

**Important:** `cadl-ranch-list.js` has four arrays in order: `azureRlcTsps`, `rlcTsps`, `azureModularTsps`, `modularTsps`. Verify a match is inside `azureModularTsps` by checking line numbers:
**Important:** `spector-list.js` has four arrays in order: `azureRlcTsps`, `rlcTsps`, `azureModularTsps`, `modularTsps`. Verify a match is inside `azureModularTsps` by checking line numbers:

1. Find the line of `export const azureModularTsps = [` (start)
2. Find the line of `export const modularTsps = [` (end boundary)
Expand All @@ -53,7 +53,7 @@ Then branch:

**Case C -- Entry exists but no .spec.ts:** Skip Step 4, go to Step 5.

### Step 4: Add Entry to cadl-ranch-list.js
### Step 4: Add Entry to spector-list.js

Add to the `azureModularTsps` array:

Expand All @@ -78,9 +78,9 @@ This step has two phases: first create the config and generate the client, then
2. Create `test/azureModularIntegration/generated/<path>/.gitignore` with the content shown in [.gitignore template](references/naming-and-templates.md#gitignore-template)
3. Generate the client by running:
```bash
npx tsx ./test/commands/gen-cadl-ranch.js --tag=azure-modular --filter=<path>
npx tsx ./test/commands/gen-spector.js --tag=azure-modular --filter=<path>
```
4. **Verify generation succeeded:** Check that `test/azureModularIntegration/generated/<path>/src/index.ts` exists and contains actual client class exports (not empty or placeholder). If the file is missing or empty, **stop** — remove the entry from `cadl-ranch-list.js`, delete the generated directory, and report that generation is not supported for this path.
4. **Verify generation succeeded:** Check that `test/azureModularIntegration/generated/<path>/src/index.ts` exists and contains actual client class exports (not empty or placeholder). If the file is missing or empty, **stop** — remove the entry from `spector-list.js`, delete the generated directory, and report that generation is not supported for this path.
5. Read `test/azureModularIntegration/generated/<path>/src/index.ts` to discover the client class name, method signatures, and operation groups.

**Phase 2 -- .spec.ts file:**
Expand Down Expand Up @@ -157,10 +157,10 @@ For each new test path, these are the files that should be committed:

| File | Action |
| -------------------------------------------------------------- | ------------------------------------------ |
| `test/commands/cadl-ranch-list.js` | Modified (new entry in `azureModularTsps`) |
| `test/commands/spector-list.js` | Modified (new entry in `azureModularTsps`) |
| `test/azureModularIntegration/generated/<path>/.gitignore` | Created |
| `test/azureModularIntegration/generated/<path>/tspconfig.yaml` | Created |
| `test/azureModularIntegration/generated/<path>/src/index.d.ts` | Generated (by gen-cadl-ranch.js) |
| `test/azureModularIntegration/generated/<path>/src/index.d.ts` | Generated (by gen-spector.js) |
| `test/azureModularIntegration/<camelCaseName>.spec.ts` | Created |

Do **not** commit these files:
Expand All @@ -177,5 +177,5 @@ Do **not** commit these files:
| Constructor mismatch | Read the generated client's `index.ts` for the actual signature |
| Assertion mismatch | Re-read `mockapi.ts` for exact expected values |
| Formatting CI fails | Run `pnpm format` at repo root before committing |
| Generation produces no output | Remove path from `cadl-ranch-list.js`; emitter doesn't support it |
| Generation produces no output | Remove path from `spector-list.js`; emitter doesn't support it |
| Test passes locally but body is undefined | Check generated code for placeholder types like `__PLACEHOLDER_*__` — emitter bug |
4 changes: 2 additions & 2 deletions .scripts/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ stages:
inputs:
artifactName: packages
path: $(Build.ArtifactStagingDirectory)
- job: HLC_Generation
- job: AutoRest_Generation
dependsOn: Build
variables:
- template: globals.yml
Expand All @@ -138,7 +138,7 @@ stages:
- template: build.yml
- script: npm run generate-swaggers
workingDirectory: $(Build.SourcesDirectory)/packages/autorest.typescript
displayName: "Generate HLC Test Clients"
displayName: "Generate AutoRest Test Clients"
- script: npm run check:tree
workingDirectory: $(Build.SourcesDirectory)/packages/autorest.typescript
displayName: "Check git Tree"
Expand Down
4 changes: 2 additions & 2 deletions .scripts/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ pool:
stages:
- stage: NightlyCI
jobs:
- job: CadlRanchTest
- job: SpectorTest
steps:
- template: nightly-prepare.yml
- script: npm run integration-test-ci
workingDirectory: $(Build.SourcesDirectory)/packages/typespec-ts
displayName: "Run all Cadl-ranch test cases"
displayName: "Run all Spector test cases"
- job: UnitTest
steps:
- template: nightly-prepare.yml
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"name": "[TypeSpec] Debug generate integration code",
"request": "launch",
"cwd": "${workspaceFolder}/packages/typespec-ts",
"runtimeArgs": ["tsx", "./test/commands/gen-cadl-ranch.js", "--tag=rlc"],
"runtimeArgs": ["tsx", "./test/commands/gen-spector.js", "--tag=rlc"],
"runtimeExecutable": "npx",
"skipFiles": ["<node_internals>/**"],
"type": "pwa-node",
Expand Down Expand Up @@ -173,4 +173,4 @@
"outFiles": ["${workspaceFolder}/packages/*/dist/**/*.js"]
}
]
}
}
6 changes: 3 additions & 3 deletions packages/typespec-ts/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ npm run smoke-test

Whenever you work on adding a feature/fixing a bug, this would probably be your first step. You create a test case and then run it through the generator, see the result, modify the generator, run it again and so on, until you get the desired output.

1. Pick up a typespec as your test input in cadl-ranch. Below are some examples
1. Pick up a typespec as your test input in spector. Below are some examples

Let us say your test input is `authentication/api-key/main.tsp` in @azure-tools/cadl-ranch-specs.
Let us say your test input is `authentication/api-key/main.tsp` in @typespec/http-specs or @azure-tools/azure-http-specs.

1. Now add an entry to the TypeSpecRanchConfig to the file [`cadl-ranch-list.ts`](./test/commands/cadl-ranch-list.ts). In the file, add the following to the array.
1. Now add an entry to the TypeSpecRanchConfig to the file [`spector-list.js`](./test/commands/spector-list.js). In the file, add the following to the array.

```typescript
{
Expand Down
8 changes: 4 additions & 4 deletions packages/typespec-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"generate-and-run:modular": "npm run generate-tsp-only:modular && npm run integration-test:alone:modular && npm run stop-test-server -- -p 3002",
"generate-and-run:azure-modular": "npm run generate-tsp-only:azure-modular && npm run integration-test:alone:azure-modular && npm run stop-test-server -- -p 3002",
"generate-tsp-only": "npm run generate-tsp-only:azure-rlc && npm run generate-tsp-only:rlc &&npm run generate-tsp-only:azure-modular && npm run generate-tsp-only:modular",
"generate-tsp-only:rlc": "npx tsx ./test/commands/gen-cadl-ranch.js --tag=rlc",
"generate-tsp-only:azure-rlc": "npx tsx ./test/commands/gen-cadl-ranch.js --tag=azure-rlc",
"generate-tsp-only:modular": "npx tsx ./test/commands/gen-cadl-ranch.js --tag=modular",
"generate-tsp-only:azure-modular": "npx tsx ./test/commands/gen-cadl-ranch.js --tag=azure-modular",
"generate-tsp-only:rlc": "npx tsx ./test/commands/gen-spector.js --tag=rlc",
"generate-tsp-only:azure-rlc": "npx tsx ./test/commands/gen-spector.js --tag=azure-rlc",
"generate-tsp-only:modular": "npx tsx ./test/commands/gen-spector.js --tag=modular",
"generate-tsp-only:azure-modular": "npx tsx ./test/commands/gen-spector.js --tag=azure-modular",
"regen-test-baselines": "npm run generate-tsp-only",
"integration-test:alone": "npm run integration-test:alone:rlc && npm run integration-test:alone:azure-rlc && npm run integration-test:alone:modular && npm run integration-test:alone:azure-modular",
"integration-test:alone:rlc": "vitest run --project integration-rlc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// id: "123",
// profileImage: {
// contents: fs.createReadStream(imgPath),
// // must specify a filename due to cadl-ranch limitations
// // must specify a filename due to spector limitations
// filename: "test.jpg"
// }
// });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
azureModularTsps,
azureRlcTsps,
rlcTsps
} from "./cadl-ranch-list.js";
} from "./spector-list.js";
import { runTypespec } from "./run.js";

async function generateTypeSpecs(tag = "rlc", isDebugging, pathFilter) {
Expand Down Expand Up @@ -68,12 +68,12 @@ async function main() {

let exitCode = 0;
try {
console.time("generate-cadl-ranch");
console.time("generate-spector");
await main();
} catch (e) {
console.error(e);
exitCode = 1;
} finally {
console.timeEnd("generate-cadl-ranch");
console.timeEnd("generate-spector");
process.exit(exitCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Multipart Client", () => {
id: "123",
profileImage: {
contents: fs.createReadStream(imgPath),
// must specify a filename due to cadl-ranch limitations
// must specify a filename due to spector limitations
filename: "test.jpg"
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# wrap-non-model-return wraps string scalar response with body property

When `wrap-non-model-return` is enabled, scalar/non-model responses are wrapped with a `body` property to maintain HLC compatibility.
When `wrap-non-model-return` is enabled, scalar/non-model responses are wrapped with a `body` property to maintain AutoRest backward compatibility.

## TypeSpec

Expand Down Expand Up @@ -281,7 +281,7 @@ export async function get(

# wrap-non-model-return does not wrap array-of-models response

Array-of-models responses (Composite kind) are not wrapped — they are returned as `Resource[]` directly (matching HLC behavior where PropertyKind.Composite means no body wrapper).
Array-of-models responses (Composite kind) are not wrapped — they are returned as `Resource[]` directly (matching AutoRest behavior where PropertyKind.Composite means no body wrapper).

## TypeSpec

Expand Down Expand Up @@ -854,7 +854,7 @@ export async function getString(
# wrap-non-model-return wraps LRO string response with body property

When `wrap-non-model-return` is enabled, LRO operations with non-model final result types
(e.g., string) should also be wrapped in a response type alias for HLC compatibility.
(e.g., string) should also be wrapped in a response type alias for AutoRest backward compatibility.

## TypeSpec

Expand Down Expand Up @@ -952,7 +952,7 @@ export function getIkeSas(

When both `wrap-non-model-return` and `head-as-boolean` are enabled and the operation is a HEAD request with no response body,
the response is wrapped as `{ body: boolean }` to indicate resource existence (true = exists, false = not found).
This matches HLC behavior for HEAD operations.
This matches AutoRest behavior for HEAD operations.

## TypeSpec

Expand Down
Loading