Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the cadl-ranch version to latest part 1 #1907

Merged
merged 8 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
136 changes: 36 additions & 100 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function getParameterSchema(
typeName: schema.name
};
}
if (type === "Array<string>") {
if (type === "Array<string>" || type === "Array<number>") {
const serializeInfo = getSpecialSerializeInfo(parameter);
if (serializeInfo.hasMultiCollection || serializeInfo.hasPipeCollection || serializeInfo.hasSsvCollection || serializeInfo.hasTsvCollection) {
type = "string";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export function buildPipeCollection(items: string[]): string {
export function buildPipeCollection(items: string[] | number[]): string {
MaryGao marked this conversation as resolved.
Show resolved Hide resolved
return items.join("|");
}

export function buildSsvCollection(items: string[]): string {
export function buildSsvCollection(items: string[] | number[]): string {
return items.join(" ");
}

export function buildTsvCollection(items: string[]) {
export function buildTsvCollection(items: string[] | number[]) {
return items.join("\t");
}
8 changes: 4 additions & 4 deletions packages/rlc-common/src/static/serializeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ export function buildMultiCollection(
}`;

export const buildPipeCollectionContent = `
export function buildPipeCollection(items: string[]): string {
export function buildPipeCollection(items: string[] | number[]): string {
return items.join("|");
}`;

export const buildSsvCollectionContent = `
export function buildSsvCollection(items: string[]): string {
export function buildSsvCollection(items: string[] | number[]): string {
return items.join(" ");
}`;

export const buildTsvCollectionContent = `
export function buildTsvCollection(items: string[]) {
export function buildTsvCollection(items: string[] | number[]) {
return items.join("\\t");
}`;

export const buildCsvCollectionContent = `
export function buildCsvCollection(items: string[]) {
export function buildCsvCollection(items: string[] | number[]) {
return items.join(",");
}`;
6 changes: 3 additions & 3 deletions packages/typespec-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"ts-node": "^10.9.1",
"typescript": "~5.0.0",
"prettier": "~2.7.1",
"@azure-tools/cadl-ranch-specs": "^0.15.4",
"@azure-tools/cadl-ranch-expect": "^0.3.2",
"@azure-tools/cadl-ranch": "^0.4.17",
"@azure-tools/cadl-ranch-specs": "^0.16.2",
"@azure-tools/cadl-ranch-expect": "^0.4.0",
"@azure-tools/cadl-ranch": "^0.5.1",
"chalk": "^4.0.0",
"@azure-rest/core-client": "^1.1.3",
"@azure/core-auth": "^1.3.2",
Expand Down
7 changes: 6 additions & 1 deletion packages/typespec-ts/src/transform/transformParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ function getParameterMetadata(
const name = getParameterName(parameter.name);
let description =
getFormattedPropertyDoc(program, parameter.param, schema) ?? "";
if (type === "string[]" || type === "Array<string>") {
if (
type === "string[]" ||
type === "Array<string>" ||
type === "number[]" ||
type === "Array<number>"
) {
const serializeInfo = getSpecialSerializeInfo(parameter);
if (
serializeInfo.hasMultiCollection ||
Expand Down
8 changes: 6 additions & 2 deletions packages/typespec-ts/test/commands/cadl-ranch-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ export interface CadlRanchConfig {

export const cadls: CadlRanchConfig[] = [
{
outputPath: "encode",
outputPath: "encode/duration",
inputPath: "encode/duration"
},
{
outputPath: "encode/datetime",
inputPath: "encode/datetime"
},
{
outputPath: "sharedRoute",
inputPath: "shared-route"
Expand Down Expand Up @@ -55,7 +59,7 @@ export const cadls: CadlRanchConfig[] = [
},
{
outputPath: "lro/lroRPC",
inputPath: "azure/core/lro/rpc"
inputPath: "azure/core/lro/rpc/legacy"
},
{
outputPath: "models/inheritance",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { assert } from "chai";
import CollectionFormatClientFactory, {
buildCsvCollection,
buildMultiCollection,
buildPipeCollection,
buildSsvCollection,
buildTsvCollection,
CollectionFormatClient
} from "./generated/parameters/collection-format/src/index.js";
import { buildCsvCollection } from "./generated/encode/src/serializeHelper.js";
describe("Collection Format Rest Client", () => {
let client: CollectionFormatClient;
const colors = ["blue", "red", "green"];
Expand Down
Loading
Loading