-
Notifications
You must be signed in to change notification settings - Fork 80
Support encode int as string #2838
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 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2ece7a5
Update the encode
MaryGao 5f93574
Enable the encode cases
MaryGao 0219ec5
Refine the test cases
MaryGao 58c6385
add encode numeric rlc case
v-jiaodi 33f9e50
add encode numeric modular case
v-jiaodi 89a9cb4
Merge remote-tracking branch 'origin/main' into support-encode-string…
MaryGao 3396792
Update the encode type for integer
MaryGao 6520b77
Update the modular cases for encode
MaryGao 1408710
Refactor the code a little
MaryGao b5f8ced
Update the type info
MaryGao d7fa66d
Merge branch 'main' of https://github.com/Azure/autorest.typescript i…
v-jiaodi 8016966
regen
v-jiaodi 71626d6
update
v-jiaodi db7b9c9
Merge to the latest main
MaryGao c25a0b3
Merge branch 'main' into support-encode-string-to-int
MaryGao 92626c4
Revert change in modular
MaryGao 44dcd92
Update the encode int as string for modular support
MaryGao fefdf23
Update the raw models
MaryGao 538b2e4
Update packages/typespec-ts/test/unit/modelsGenerator.spec.ts
MaryGao a401ae3
Remove un-necessary quotes
MaryGao 02bcf3d
Refactor the empty diagnostic configs
MaryGao 3ad6972
Merge branch 'main' into support-encode-string-to-int
MaryGao 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
47 changes: 47 additions & 0 deletions
47
packages/typespec-ts/test/integration/encodeNumeric.spec.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,47 @@ | ||
| import { assert } from "chai"; | ||
| import EncodeNumericClientFactory, { | ||
| NumericClient | ||
| } from "./generated/encode/numeric/src/index.js"; | ||
| describe("EncodeNumericClient Rest Client", () => { | ||
| let client: NumericClient; | ||
|
|
||
| beforeEach(() => { | ||
| client = EncodeNumericClientFactory({ | ||
| allowInsecureConnection: true | ||
| }); | ||
| }); | ||
|
|
||
| describe("property", () => { | ||
| it(`should post safeint property`, async () => { | ||
| const result = await client | ||
| .path(`/encode/numeric/property/safeint`) | ||
| .post({ | ||
| body: { | ||
| value: "10000000000" | ||
| } | ||
| }); | ||
| assert.strictEqual(result.status, "200"); | ||
| assert.strictEqual(result.body.value, "10000000000"); | ||
| }); | ||
|
|
||
| it(`should post uint32 property`, async () => { | ||
| const result = await client.path(`/encode/numeric/property/uint32`).post({ | ||
| body: { | ||
| value: "1" | ||
| } | ||
| }); | ||
| assert.strictEqual(result.status, "200"); | ||
| assert.strictEqual(result.body.value, "1"); | ||
| }); | ||
|
|
||
| it(`should post uint8 property`, async () => { | ||
| const result = await client.path(`/encode/numeric/property/uint8`).post({ | ||
| body: { | ||
| value: "255" | ||
| } | ||
| }); | ||
| assert.strictEqual(result.status, "200"); | ||
| assert.strictEqual(result.body.value, "255"); | ||
| }); | ||
| }); | ||
| }); |
6 changes: 6 additions & 0 deletions
6
packages/typespec-ts/test/integration/generated/encode/numeric/.gitignore
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,6 @@ | ||
| /** | ||
| !/src | ||
| /src/** | ||
| !/src/index.d.ts | ||
| !/.gitignore | ||
| !/tspconfig.yaml |
92 changes: 92 additions & 0 deletions
92
packages/typespec-ts/test/integration/generated/encode/numeric/src/index.d.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,92 @@ | ||
| import { Client } from '@azure-rest/core-client'; | ||
| import { ClientOptions } from '@azure-rest/core-client'; | ||
| import { HttpResponse } from '@azure-rest/core-client'; | ||
| import { RequestParameters } from '@azure-rest/core-client'; | ||
| import { StreamableMethod } from '@azure-rest/core-client'; | ||
|
|
||
| declare function createClient(options?: NumericClientOptions): NumericClient; | ||
| export default createClient; | ||
|
|
||
| export declare type NumericClient = Client & { | ||
| path: Routes; | ||
| }; | ||
|
|
||
| export declare interface NumericClientOptions extends ClientOptions { | ||
| } | ||
|
|
||
| export declare interface PropertySafeintAsString200Response extends HttpResponse { | ||
| status: "200"; | ||
| body: SafeintAsStringPropertyOutput; | ||
| } | ||
|
|
||
| export declare interface PropertySafeintAsStringBodyParam { | ||
| body: SafeintAsStringProperty; | ||
| } | ||
|
|
||
| export declare type PropertySafeintAsStringParameters = PropertySafeintAsStringBodyParam & RequestParameters; | ||
|
|
||
| export declare interface PropertyUint32AsStringOptional200Response extends HttpResponse { | ||
| status: "200"; | ||
| body: Uint32AsStringPropertyOutput; | ||
| } | ||
|
|
||
| export declare interface PropertyUint32AsStringOptionalBodyParam { | ||
| body: Uint32AsStringProperty; | ||
| } | ||
|
|
||
| export declare type PropertyUint32AsStringOptionalParameters = PropertyUint32AsStringOptionalBodyParam & RequestParameters; | ||
|
|
||
| export declare interface PropertyUint8AsString200Response extends HttpResponse { | ||
| status: "200"; | ||
| body: Uint8AsStringPropertyOutput; | ||
| } | ||
|
|
||
| export declare interface PropertyUint8AsStringBodyParam { | ||
| body: Uint8AsStringProperty; | ||
| } | ||
|
|
||
| export declare type PropertyUint8AsStringParameters = PropertyUint8AsStringBodyParam & RequestParameters; | ||
|
|
||
| export declare interface Routes { | ||
| (path: "/encode/numeric/property/safeint"): SafeintAsString; | ||
| (path: "/encode/numeric/property/uint32"): Uint32AsStringOptional; | ||
| (path: "/encode/numeric/property/uint8"): Uint8AsString; | ||
| } | ||
|
|
||
| export declare interface SafeintAsString { | ||
| post(options: PropertySafeintAsStringParameters): StreamableMethod<PropertySafeintAsString200Response>; | ||
| } | ||
|
|
||
| export declare interface SafeintAsStringProperty { | ||
| value: string; | ||
| } | ||
|
|
||
| export declare interface SafeintAsStringPropertyOutput { | ||
| value: string; | ||
| } | ||
|
|
||
| export declare interface Uint32AsStringOptional { | ||
| post(options: PropertyUint32AsStringOptionalParameters): StreamableMethod<PropertyUint32AsStringOptional200Response>; | ||
| } | ||
|
|
||
| export declare interface Uint32AsStringProperty { | ||
| value?: string; | ||
| } | ||
|
|
||
| export declare interface Uint32AsStringPropertyOutput { | ||
| value?: string; | ||
| } | ||
|
|
||
| export declare interface Uint8AsString { | ||
| post(options: PropertyUint8AsStringParameters): StreamableMethod<PropertyUint8AsString200Response>; | ||
| } | ||
|
|
||
| export declare interface Uint8AsStringProperty { | ||
| value: string; | ||
| } | ||
|
|
||
| export declare interface Uint8AsStringPropertyOutput { | ||
| value: string; | ||
| } | ||
|
|
||
| export { } |
12 changes: 12 additions & 0 deletions
12
packages/typespec-ts/test/integration/generated/encode/numeric/tspconfig.yaml
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,12 @@ | ||
| emit: | ||
| - "@azure-tools/typespec-ts" | ||
| options: | ||
| "@azure-tools/typespec-ts": | ||
| "emitter-output-dir": "{project-root}" | ||
| generateMetadata: true | ||
| addCredentials: false | ||
| azureSdkForJs: false | ||
| isTypeSpecTest: true | ||
| enableOperationGroup: true | ||
| packageDetails: | ||
| name: "@msinternal/encode-numeric" |
37 changes: 37 additions & 0 deletions
37
packages/typespec-ts/test/modularIntegration/encodeNumeric.spec.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,37 @@ | ||
| import { assert } from "chai"; | ||
| import { NumericClient } from "./generated/encode/numeric/src/index.js"; | ||
| describe("EncodeNumericClient Rest Client", () => { | ||
| let client: NumericClient; | ||
|
|
||
| beforeEach(() => { | ||
| client = new NumericClient({ | ||
| endpoint: "http://localhost:3002", | ||
| allowInsecureConnection: true, | ||
| retryOptions: { | ||
| maxRetries: 0 | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("query", () => { | ||
| it(`should get safeint numeric`, async () => { | ||
| const result = await client.property.safeintAsString({ | ||
| value: "10000000000" | ||
| }); | ||
| console.log(result); | ||
| assert.strictEqual(result.value, "10000000000"); | ||
| }); | ||
|
|
||
| it(`should get uint32 numeric`, async () => { | ||
| const result = await client.property.uint32AsStringOptional({ | ||
| value: "1" | ||
| }); | ||
| assert.strictEqual(result.value, "1"); | ||
| }); | ||
|
|
||
| it(`should get uint8 numeric`, async () => { | ||
| const result = await client.property.uint8AsString({ value: "255" }); | ||
| assert.strictEqual(result.value, "255"); | ||
| }); | ||
| }); | ||
| }); |
6 changes: 6 additions & 0 deletions
6
packages/typespec-ts/test/modularIntegration/generated/encode/numeric/.gitignore
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,6 @@ | ||
| /** | ||
| !/src | ||
| /src/** | ||
| !/src/index.d.ts | ||
| !/.gitignore | ||
| !/tspconfig.yaml |
42 changes: 42 additions & 0 deletions
42
packages/typespec-ts/test/modularIntegration/generated/encode/numeric/src/index.d.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,42 @@ | ||
| import { ClientOptions } from '@azure-rest/core-client'; | ||
| import { OperationOptions } from '@azure-rest/core-client'; | ||
| import { Pipeline } from '@azure/core-rest-pipeline'; | ||
|
|
||
| export declare class NumericClient { | ||
| private _client; | ||
| readonly pipeline: Pipeline; | ||
| constructor(options?: NumericClientOptionalParams); | ||
| readonly property: PropertyOperations; | ||
| } | ||
|
|
||
| export declare interface NumericClientOptionalParams extends ClientOptions { | ||
| } | ||
|
|
||
| export declare interface PropertyOperations { | ||
| safeintAsString: (value: SafeintAsStringProperty, options?: PropertySafeintAsStringOptionalParams) => Promise<SafeintAsStringProperty>; | ||
| uint32AsStringOptional: (value: Uint32AsStringProperty, options?: PropertyUint32AsStringOptionalOptionalParams) => Promise<Uint32AsStringProperty>; | ||
| uint8AsString: (value: Uint8AsStringProperty, options?: PropertyUint8AsStringOptionalParams) => Promise<Uint8AsStringProperty>; | ||
| } | ||
|
|
||
| export declare interface PropertySafeintAsStringOptionalParams extends OperationOptions { | ||
| } | ||
|
|
||
| export declare interface PropertyUint32AsStringOptionalOptionalParams extends OperationOptions { | ||
| } | ||
|
|
||
| export declare interface PropertyUint8AsStringOptionalParams extends OperationOptions { | ||
| } | ||
|
|
||
| export declare interface SafeintAsStringProperty { | ||
| value: number; | ||
| } | ||
|
|
||
| export declare interface Uint32AsStringProperty { | ||
| value?: number; | ||
| } | ||
|
|
||
| export declare interface Uint8AsStringProperty { | ||
| value: number; | ||
| } | ||
|
|
||
| export { } |
15 changes: 15 additions & 0 deletions
15
packages/typespec-ts/test/modularIntegration/generated/encode/numeric/tspconfig.yaml
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,15 @@ | ||
| emit: | ||
| - "@azure-tools/typespec-ts" | ||
| options: | ||
| "@azure-tools/typespec-ts": | ||
| "emitter-output-dir": "{project-root}" | ||
| generateMetadata: true | ||
| generateTest: false | ||
| addCredentials: false | ||
| azureSdkForJs: false | ||
| isTypeSpecTest: true | ||
| enableOperationGroup: true | ||
| isModularLibrary: true | ||
| hierarchyClient: false | ||
| packageDetails: | ||
| name: "@msinternal/encode-numeric" |
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
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.
Uh oh!
There was an error while loading. Please reload this page.