Skip to content
Draft
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 packages/typespec-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"stop-test-server": "npx tsp-spector server stop",
"unit-test": "npm-run-all --parallel unit-test:rlc unit-test:modular",
"unit-test:rlc": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register --experimental-specifier-resolution=node --experimental-modules=true --timeout 36000 './test/unit/**/*.spec.ts'",
"unit-test:modular": "cross-env TS_NODE_PROJECT=tsconfig.test.json NODE_OPTIONS='--max-old-space-size=8192' mocha -r ts-node/register --experimental-specifier-resolution=node --experimental-modules=true --no-timeout './test/modularUnit/**/*.spec.ts' --reporter-options maxDiffSize=20000",
"unit-test:modular": "cross-env TS_NODE_PROJECT=tsconfig.test.json mocha -r ts-node/register --experimental-specifier-resolution=node --experimental-modules=true --no-timeout './test/modularUnit/**/*.spec.ts' --reporter-options maxDiffSize=20000",
"regen-docs": "npm run build && tspd doc . --enable-experimental --output-dir ./website/src/content/docs/docs/emitters/clients/typespec-ts/reference --skip-js"
},
"author": "Jose Heredia <joheredi@microsoft.com>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1275,4 +1275,85 @@ export function bar(
{ itemName: "tests", nextLinkName: "next" },
);
}
```

# only: should support non-model type as response from TypeSpec

## TypeSpec

```tsp
import "@typespec/http";
import "@azure-tools/typespec-client-generator-core";
using TypeSpec.Http;
using Azure.ClientGenerator.Core;

@service(#{
title: "Test Service"
})
namespace testService;
model ListTestResult is string[];

model Test {
id: string;
}

@route("/list-get")
@post
op bar(): ListTestResult;
```

The config would be like:

```yaml
withRawContent: true
```

## models

```ts models
// (file was not generated)
```

## Operations

```ts operations
import { testServiceContext as Client } from "./index.js";
import { BarOptionalParams } from "./options.js";
import {
StreamableMethod,
PathUncheckedResponse,
createRestError,
operationOptionsToRequestParameters,
} from "@azure-rest/core-client";

export function _barSend(
context: Client,
options: BarOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path("/list-get")
.post({
...operationOptionsToRequestParameters(options),
headers: { accept: "application/json", ...options.requestOptions?.headers },
});
}

export async function _barDeserialize(result: PathUncheckedResponse): Promise<string[]> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}

return result.body.map((p: any) => {
return p;
});
}

export async function bar(
context: Client,
options: BarOptionalParams = { requestOptions: {} },
): Promise<string[]> {
const result = await _barSend(context, options);
return _barDeserialize(result);
}
```
Loading