-
Notifications
You must be signed in to change notification settings - Fork 80
Add coverage cases for arrays-item-types in cadl-ranch #2103
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
654367b
generate test SDK for array
zzhxiaofeng efdbd9d
discard commit to resove conflict for update latest code
v-jiaodi 96755ff
Merge branch 'Azure:main' into addcoverageforarray
v-jiaodi 4c0d1b6
generate code with latest repo
v-jiaodi bb2ba11
fix array item type optionality
qiaozha ffcc449
Update packages/typespec-ts/src/modular/helpers/operationHelpers.ts
qiaozha a5065ab
add test case
v-jiaodi cdc6376
fix test
qiaozha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/typespec-ts/test/modularIntegration/generated/arrays/items/src/ArrayClient.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { Pipeline } from "@azure/core-rest-pipeline"; | ||
| import { | ||
| getInt32ValueOperations, | ||
| Int32ValueOperations, | ||
| } from "./classic/int32Value/index.js"; | ||
| import { | ||
| getInt64ValueOperations, | ||
| Int64ValueOperations, | ||
| } from "./classic/int64Value/index.js"; | ||
| import { | ||
| getBooleanValueOperations, | ||
| BooleanValueOperations, | ||
| } from "./classic/booleanValue/index.js"; | ||
| import { | ||
| getStringValueOperations, | ||
| StringValueOperations, | ||
| } from "./classic/stringValue/index.js"; | ||
| import { | ||
| getFloat32ValueOperations, | ||
| Float32ValueOperations, | ||
| } from "./classic/float32Value/index.js"; | ||
| import { | ||
| getDatetimeValueOperations, | ||
| DatetimeValueOperations, | ||
| } from "./classic/datetimeValue/index.js"; | ||
| import { | ||
| getDurationValueOperations, | ||
| DurationValueOperations, | ||
| } from "./classic/durationValue/index.js"; | ||
| import { | ||
| getUnknownValueOperations, | ||
| UnknownValueOperations, | ||
| } from "./classic/unknownValue/index.js"; | ||
| import { | ||
| getModelValueOperations, | ||
| ModelValueOperations, | ||
| } from "./classic/modelValue/index.js"; | ||
| import { | ||
| getNullableFloatValueOperations, | ||
| NullableFloatValueOperations, | ||
| } from "./classic/nullableFloatValue/index.js"; | ||
| import { createArray, ArrayClientOptions, ArrayContext } from "./api/index.js"; | ||
|
|
||
| export { ArrayClientOptions } from "./api/ArrayContext.js"; | ||
|
|
||
| export class ArrayClient { | ||
| private _client: ArrayContext; | ||
| /** The pipeline used by this client to make requests */ | ||
| public readonly pipeline: Pipeline; | ||
|
|
||
| /** Illustrates various of dictionaries. */ | ||
| constructor(options: ArrayClientOptions = {}) { | ||
| this._client = createArray(options); | ||
| this.pipeline = this._client.pipeline; | ||
| this.int32Value = getInt32ValueOperations(this._client); | ||
| this.int64Value = getInt64ValueOperations(this._client); | ||
| this.booleanValue = getBooleanValueOperations(this._client); | ||
| this.stringValue = getStringValueOperations(this._client); | ||
| this.float32Value = getFloat32ValueOperations(this._client); | ||
| this.datetimeValue = getDatetimeValueOperations(this._client); | ||
| this.durationValue = getDurationValueOperations(this._client); | ||
| this.unknownValue = getUnknownValueOperations(this._client); | ||
| this.modelValue = getModelValueOperations(this._client); | ||
| this.nullableFloatValue = getNullableFloatValueOperations(this._client); | ||
| } | ||
|
|
||
| /** The operation groups for Int32Value */ | ||
| public readonly int32Value: Int32ValueOperations; | ||
| /** The operation groups for Int64Value */ | ||
| public readonly int64Value: Int64ValueOperations; | ||
| /** The operation groups for BooleanValue */ | ||
| public readonly booleanValue: BooleanValueOperations; | ||
| /** The operation groups for StringValue */ | ||
| public readonly stringValue: StringValueOperations; | ||
| /** The operation groups for Float32Value */ | ||
| public readonly float32Value: Float32ValueOperations; | ||
| /** The operation groups for DatetimeValue */ | ||
| public readonly datetimeValue: DatetimeValueOperations; | ||
| /** The operation groups for DurationValue */ | ||
| public readonly durationValue: DurationValueOperations; | ||
| /** The operation groups for UnknownValue */ | ||
| public readonly unknownValue: UnknownValueOperations; | ||
| /** The operation groups for ModelValue */ | ||
| public readonly modelValue: ModelValueOperations; | ||
| /** The operation groups for NullableFloatValue */ | ||
| public readonly nullableFloatValue: NullableFloatValueOperations; | ||
| } |
16 changes: 16 additions & 0 deletions
16
packages/typespec-ts/test/modularIntegration/generated/arrays/items/src/api/ArrayContext.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { ClientOptions } from "@azure-rest/core-client"; | ||
| import { ArrayContext } from "../rest/index.js"; | ||
| import getClient from "../rest/index.js"; | ||
|
|
||
| export interface ArrayClientOptions extends ClientOptions {} | ||
|
|
||
| export { ArrayContext } from "../rest/index.js"; | ||
|
|
||
| /** Illustrates various of dictionaries. */ | ||
| export function createArray(options: ArrayClientOptions = {}): ArrayContext { | ||
| const clientContext = getClient(options); | ||
| return clientContext; | ||
| } |
73 changes: 73 additions & 0 deletions
73
.../typespec-ts/test/modularIntegration/generated/arrays/items/src/api/booleanValue/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { | ||
| ArrayContext as Client, | ||
| BooleanValueGet200Response, | ||
| BooleanValuePut204Response, | ||
| } from "../../rest/index.js"; | ||
| import { | ||
| StreamableMethod, | ||
| operationOptionsToRequestParameters, | ||
| createRestError, | ||
| } from "@azure-rest/core-client"; | ||
| import { | ||
| BooleanValueGetOptions, | ||
| BooleanValuePutOptions, | ||
| } from "../../models/options.js"; | ||
|
|
||
| export function _booleanValueGetSend( | ||
| context: Client, | ||
| options: BooleanValueGetOptions = { requestOptions: {} }, | ||
| ): StreamableMethod<BooleanValueGet200Response> { | ||
| return context | ||
| .path("/type/array/boolean") | ||
| .get({ ...operationOptionsToRequestParameters(options) }); | ||
| } | ||
|
|
||
| export async function _booleanValueGetDeserialize( | ||
| result: BooleanValueGet200Response, | ||
| ): Promise<boolean[]> { | ||
| if (result.status !== "200") { | ||
| throw createRestError(result); | ||
| } | ||
|
|
||
| return result.body; | ||
| } | ||
|
|
||
| export async function booleanValueGet( | ||
| context: Client, | ||
| options: BooleanValueGetOptions = { requestOptions: {} }, | ||
| ): Promise<boolean[]> { | ||
| const result = await _booleanValueGetSend(context, options); | ||
| return _booleanValueGetDeserialize(result); | ||
| } | ||
|
|
||
| export function _booleanValuePutSend( | ||
| context: Client, | ||
| body: boolean[], | ||
| options: BooleanValuePutOptions = { requestOptions: {} }, | ||
| ): StreamableMethod<BooleanValuePut204Response> { | ||
| return context | ||
| .path("/type/array/boolean") | ||
| .put({ ...operationOptionsToRequestParameters(options), body: body }); | ||
| } | ||
|
|
||
| export async function _booleanValuePutDeserialize( | ||
| result: BooleanValuePut204Response, | ||
| ): Promise<void> { | ||
| if (result.status !== "204") { | ||
| throw createRestError(result); | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| export async function booleanValuePut( | ||
| context: Client, | ||
| body: boolean[], | ||
| options: BooleanValuePutOptions = { requestOptions: {} }, | ||
| ): Promise<void> { | ||
| const result = await _booleanValuePutSend(context, body, options); | ||
| return _booleanValuePutDeserialize(result); | ||
| } |
73 changes: 73 additions & 0 deletions
73
...typespec-ts/test/modularIntegration/generated/arrays/items/src/api/datetimeValue/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { | ||
| ArrayContext as Client, | ||
| DatetimeValueGet200Response, | ||
| DatetimeValuePut204Response, | ||
| } from "../../rest/index.js"; | ||
| import { | ||
| StreamableMethod, | ||
| operationOptionsToRequestParameters, | ||
| createRestError, | ||
| } from "@azure-rest/core-client"; | ||
| import { | ||
| DatetimeValueGetOptions, | ||
| DatetimeValuePutOptions, | ||
| } from "../../models/options.js"; | ||
|
|
||
| export function _datetimeValueGetSend( | ||
| context: Client, | ||
| options: DatetimeValueGetOptions = { requestOptions: {} }, | ||
| ): StreamableMethod<DatetimeValueGet200Response> { | ||
| return context | ||
| .path("/type/array/datetime") | ||
| .get({ ...operationOptionsToRequestParameters(options) }); | ||
| } | ||
|
|
||
| export async function _datetimeValueGetDeserialize( | ||
| result: DatetimeValueGet200Response, | ||
| ): Promise<Date[]> { | ||
| if (result.status !== "200") { | ||
| throw createRestError(result); | ||
| } | ||
|
|
||
| return !result.body ? result.body : result.body.map((p) => new Date(p)); | ||
| } | ||
|
|
||
| export async function datetimeValueGet( | ||
| context: Client, | ||
| options: DatetimeValueGetOptions = { requestOptions: {} }, | ||
| ): Promise<Date[]> { | ||
| const result = await _datetimeValueGetSend(context, options); | ||
| return _datetimeValueGetDeserialize(result); | ||
| } | ||
|
|
||
| export function _datetimeValuePutSend( | ||
| context: Client, | ||
| body: Date[], | ||
| options: DatetimeValuePutOptions = { requestOptions: {} }, | ||
| ): StreamableMethod<DatetimeValuePut204Response> { | ||
| return context | ||
| .path("/type/array/datetime") | ||
| .put({ ...operationOptionsToRequestParameters(options), body: body }); | ||
| } | ||
|
|
||
| export async function _datetimeValuePutDeserialize( | ||
| result: DatetimeValuePut204Response, | ||
| ): Promise<void> { | ||
| if (result.status !== "204") { | ||
| throw createRestError(result); | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| export async function datetimeValuePut( | ||
| context: Client, | ||
| body: Date[], | ||
| options: DatetimeValuePutOptions = { requestOptions: {} }, | ||
| ): Promise<void> { | ||
| const result = await _datetimeValuePutSend(context, body, options); | ||
| return _datetimeValuePutDeserialize(result); | ||
| } |
73 changes: 73 additions & 0 deletions
73
...typespec-ts/test/modularIntegration/generated/arrays/items/src/api/durationValue/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { | ||
| ArrayContext as Client, | ||
| DurationValueGet200Response, | ||
| DurationValuePut204Response, | ||
| } from "../../rest/index.js"; | ||
| import { | ||
| StreamableMethod, | ||
| operationOptionsToRequestParameters, | ||
| createRestError, | ||
| } from "@azure-rest/core-client"; | ||
| import { | ||
| DurationValueGetOptions, | ||
| DurationValuePutOptions, | ||
| } from "../../models/options.js"; | ||
|
|
||
| export function _durationValueGetSend( | ||
| context: Client, | ||
| options: DurationValueGetOptions = { requestOptions: {} }, | ||
| ): StreamableMethod<DurationValueGet200Response> { | ||
| return context | ||
| .path("/type/array/duration") | ||
| .get({ ...operationOptionsToRequestParameters(options) }); | ||
| } | ||
|
|
||
| export async function _durationValueGetDeserialize( | ||
| result: DurationValueGet200Response, | ||
| ): Promise<string[]> { | ||
| if (result.status !== "200") { | ||
| throw createRestError(result); | ||
| } | ||
|
|
||
| return result.body; | ||
| } | ||
|
|
||
| export async function durationValueGet( | ||
| context: Client, | ||
| options: DurationValueGetOptions = { requestOptions: {} }, | ||
| ): Promise<string[]> { | ||
| const result = await _durationValueGetSend(context, options); | ||
| return _durationValueGetDeserialize(result); | ||
| } | ||
|
|
||
| export function _durationValuePutSend( | ||
| context: Client, | ||
| body: string[], | ||
| options: DurationValuePutOptions = { requestOptions: {} }, | ||
| ): StreamableMethod<DurationValuePut204Response> { | ||
| return context | ||
| .path("/type/array/duration") | ||
| .put({ ...operationOptionsToRequestParameters(options), body: body }); | ||
| } | ||
|
|
||
| export async function _durationValuePutDeserialize( | ||
| result: DurationValuePut204Response, | ||
| ): Promise<void> { | ||
| if (result.status !== "204") { | ||
| throw createRestError(result); | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| export async function durationValuePut( | ||
| context: Client, | ||
| body: string[], | ||
| options: DurationValuePutOptions = { requestOptions: {} }, | ||
| ): Promise<void> { | ||
| const result = await _durationValuePutSend(context, body, options); | ||
| return _durationValuePutDeserialize(result); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found typespec can't not define this way playground link
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assume elementTypes are all required, for nullable, since the current nullable logic has problem, I would prefer to have another independent pr to fix it. @MaryGao let me know if you have different thoughts.