From a9892b0e3a7794f0e7b7fecc44663fc29d37f398 Mon Sep 17 00:00:00 2001 From: Michael Yanni Date: Tue, 28 Apr 2020 16:03:59 -0700 Subject: [PATCH 1/2] Allow test to run. Waiting for test server update. --- test/AutoRest.TestServer.Tests/lro.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/AutoRest.TestServer.Tests/lro.cs b/test/AutoRest.TestServer.Tests/lro.cs index 337b5179..a8b2e68b 100644 --- a/test/AutoRest.TestServer.Tests/lro.cs +++ b/test/AutoRest.TestServer.Tests/lro.cs @@ -20,7 +20,6 @@ namespace AutoRest.TestServer.Tests public LroTest(TestServerVersion version) : base(version, "lros") { } [Test] - [Ignore("https://github.com/Azure/autorest.csharp/issues/683")] public Task CustomHeaderPostAsyncSucceded() => TestStatus(async (host, pipeline) => { using var _ = ClientRequestIdScope.Start("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"); @@ -30,7 +29,6 @@ namespace AutoRest.TestServer.Tests }); [Test] - [Ignore("https://github.com/Azure/autorest.csharp/issues/683")] public Task CustomHeaderPostAsyncSucceded_Sync() => TestStatus((host, pipeline) => { using var _ = ClientRequestIdScope.Start("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"); From d5d4e6e886f10f7d02276a92ff9972e043270e5e Mon Sep 17 00:00:00 2001 From: Michael Yanni Date: Tue, 28 Apr 2020 16:46:32 -0700 Subject: [PATCH 2/2] Update test server version. Added new paging test. --- package-lock.json | 44 +- package.json | 2 +- test/AutoRest.TestServer.Tests/paging.cs | 59 ++ test/TestServerProjects/paging/CodeModel.yaml | 528 ++++++++++++------ .../Generated/Operations/PagingClient.cs | 70 +++ .../Generated/Operations/PagingRestClient.cs | 275 +++++++++ 6 files changed, 775 insertions(+), 203 deletions(-) diff --git a/package-lock.json b/package-lock.json index b73e5e82..e426e5a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "dev": true }, "@microsoft.azure/autorest.testserver": { - "version": "2.10.29", - "resolved": "https://registry.npmjs.org/@microsoft.azure/autorest.testserver/-/autorest.testserver-2.10.29.tgz", - "integrity": "sha512-VHbbPZ7K+18nNtu+MqVwYTm5tQA+sd8y/dKvDlNPLLlnRBLjbzWzC3UK8JbU/G0RtU6K7QNoSu9n4BnJnOB+BQ==", + "version": "2.10.31", + "resolved": "https://registry.npmjs.org/@microsoft.azure/autorest.testserver/-/autorest.testserver-2.10.31.tgz", + "integrity": "sha512-PCkvkLvx3AzPKtvvjyaxZiILTE6Xqk2bkL1YjoVCjfT6nbzbX5K4/6EhqicIdKTNssHg6NZSsjPgdo+sM/jO7w==", "dev": true, "requires": { "azure-storage": "^2.4.0", @@ -95,9 +95,9 @@ "dev": true }, "ajv": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz", - "integrity": "sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==", + "version": "6.12.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", + "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -1112,9 +1112,9 @@ } }, "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", "dev": true }, "is-regex": { @@ -1273,18 +1273,18 @@ "dev": true }, "mime-db": { - "version": "1.43.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", - "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", "dev": true }, "mime-types": { - "version": "2.1.26", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", - "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", "dev": true, "requires": { - "mime-db": "1.43.0" + "mime-db": "1.44.0" } }, "minimatch": { @@ -1699,9 +1699,9 @@ } }, "resolve": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.16.0.tgz", - "integrity": "sha512-LarL/PIKJvc09k1jaeT4kQb/8/7P+qV4qSnN2K80AES+OHdfZELAKVOBjxsvtToT/uLOfFbvYvKfZmV8cee7nA==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -2227,9 +2227,9 @@ "dev": true }, "ws": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz", - "integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==", + "version": "7.2.5", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.5.tgz", + "integrity": "sha512-C34cIU4+DB2vMyAbmEKossWq2ZQDr6QEyuuCzWrM9zfw1sGc0mYiJ0UnG9zzNykt49C2Fi34hvr2vssFQRS6EA==", "dev": true }, "xml2js": { diff --git a/package.json b/package.json index c0df69a3..97d62599 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "package.json intended for in-repo use only, package.json used for publishing is located in src/AutoRest.CSharp.V3/package.json", "devDependencies": { "@autorest/autorest": "https://github.com/Azure/autorest/releases/download/autorest-3.0.6222/autorest-autorest-3.0.6222.tgz", - "@microsoft.azure/autorest.testserver": "^2.10.29" + "@microsoft.azure/autorest.testserver": "^2.10.31" }, "dependencies": {} } diff --git a/test/AutoRest.TestServer.Tests/paging.cs b/test/AutoRest.TestServer.Tests/paging.cs index 3980ad0e..7bf95e02 100644 --- a/test/AutoRest.TestServer.Tests/paging.cs +++ b/test/AutoRest.TestServer.Tests/paging.cs @@ -256,6 +256,65 @@ namespace AutoRest.TestServer.Tests Assert.AreEqual(10, id); }, true); + [Test] + [IgnoreOnTestServer(TestServerVersion.V2, "Refused connection.")] + public Task PagingMultipleWithQueryParameters() => Test(async (host, pipeline) => + { + var value = 100; + var id = 1; + var product = "Product"; + var linkPart = "/paging/multiple/nextOperationWithQueryParams"; + var result = await new PagingClient(ClientDiagnostics, pipeline, host).RestClient.GetWithQueryParamsAsync(value); + var resultPage = Page.FromValues(result.Value.Values, result.Value.NextLink, result.GetRawResponse()); + while (resultPage.ContinuationToken != null) + { + Assert.AreEqual(id++, resultPage.Values.First().Properties.Id); + Assert.AreEqual(product, resultPage.Values.First().Properties.Name); + StringAssert.EndsWith(linkPart, resultPage.ContinuationToken); + result = await new PagingClient(ClientDiagnostics, pipeline, host).RestClient.NextOperationWithQueryParamsAsync(); + resultPage = Page.FromValues(result.Value.Values, result.Value.NextLink, result.GetRawResponse()); + } + Assert.AreEqual(2, id); + Assert.AreEqual(id, resultPage.Values.First().Properties.Id); + Assert.AreEqual(product, resultPage.Values.First().Properties.Name); + + id = 1; + var pageableAsync = new PagingClient(ClientDiagnostics, pipeline, host).GetWithQueryParamsAsync(value); + await foreach (var page in pageableAsync.AsPages()) + { + Assert.AreEqual(id, page.Values.First().Properties.Id); + Assert.AreEqual(product, page.Values.First().Properties.Name); + if (id == 2) + { + Assert.IsNull(page.ContinuationToken); + } + else + { + StringAssert.EndsWith(linkPart, page.ContinuationToken); + id++; + } + } + Assert.AreEqual(2, id); + + id = 1; + var pageable = new PagingClient(ClientDiagnostics, pipeline, host).GetWithQueryParams(value); + foreach (var page in pageable.AsPages()) + { + Assert.AreEqual(id, page.Values.First().Properties.Id); + Assert.AreEqual(product, page.Values.First().Properties.Name); + if (id == 2) + { + Assert.IsNull(page.ContinuationToken); + } + else + { + StringAssert.EndsWith(linkPart, page.ContinuationToken); + id++; + } + } + Assert.AreEqual(2, id); + }, true); + [Test] public Task PagingMultipleFailure() => Test(async (host, pipeline) => { diff --git a/test/TestServerProjects/paging/CodeModel.yaml b/test/TestServerProjects/paging/CodeModel.yaml index 4783d378..f79a4dfc 100644 --- a/test/TestServerProjects/paging/CodeModel.yaml +++ b/test/TestServerProjects/paging/CodeModel.yaml @@ -3,8 +3,16 @@ info: ! description: Long-running Operation for AutoRest title: AutoRest Paging Test Service schemas: ! + booleans: + - ! &ref_1 + type: boolean + language: ! + default: + name: Bool + description: simple boolean + protocol: ! {} numbers: - - ! &ref_15 + - ! &ref_16 type: integer precision: 32 language: ! @@ -12,7 +20,7 @@ schemas: ! name: Integer description: '' protocol: ! {} - - ! &ref_1 + - ! &ref_2 type: integer apiVersions: - ! @@ -23,7 +31,7 @@ schemas: ! name: Integer description: '' protocol: ! {} - - ! &ref_3 + - ! &ref_4 type: integer apiVersions: - ! @@ -43,7 +51,7 @@ schemas: ! name: String description: simple string protocol: ! {} - - ! &ref_16 + - ! &ref_17 type: string apiVersions: - ! @@ -53,7 +61,7 @@ schemas: ! name: ProductPropertiesName description: '' protocol: ! {} - - ! &ref_17 + - ! &ref_18 type: string apiVersions: - ! @@ -63,7 +71,7 @@ schemas: ! name: ProductResultValueNextLink description: '' protocol: ! {} - - ! &ref_20 + - ! &ref_21 type: string apiVersions: - ! @@ -73,7 +81,7 @@ schemas: ! name: ProductResultNextLink description: '' protocol: ! {} - - ! &ref_9 + - ! &ref_10 type: string apiVersions: - ! @@ -83,7 +91,7 @@ schemas: ! name: String description: '' protocol: ! {} - - ! &ref_21 + - ! &ref_22 type: string apiVersions: - ! @@ -94,7 +102,7 @@ schemas: ! description: '' protocol: ! {} choices: - - ! &ref_22 + - ! &ref_23 choices: - ! value: Succeeded @@ -172,17 +180,28 @@ schemas: ! name: OperationResultStatus description: The status of the request protocol: ! {} + constants: + - ! &ref_33 + type: constant + value: ! + value: true + valueType: *ref_1 + language: ! + default: + name: Constant1 + description: '' + protocol: ! {} groups: - - ! &ref_2 + - ! &ref_3 type: group properties: - ! - schema: *ref_1 + schema: *ref_2 originalParameter: - - ! &ref_29 - schema: *ref_1 - groupedBy: ! &ref_4 - schema: *ref_2 + - ! &ref_30 + schema: *ref_2 + groupedBy: ! &ref_5 + schema: *ref_3 implementation: Method language: ! default: @@ -205,11 +224,11 @@ schemas: ! description: Sets the maximum number of items to return in the response. protocol: ! {} - ! - schema: *ref_3 + schema: *ref_4 originalParameter: - - ! &ref_30 - schema: *ref_3 - groupedBy: *ref_4 + - ! &ref_31 + schema: *ref_4 + groupedBy: *ref_5 implementation: Method language: ! default: @@ -232,16 +251,16 @@ schemas: ! name: PagingGetMultiplePagesOptions description: Parameter group protocol: ! {} - - ! &ref_5 + - ! &ref_6 type: group properties: - ! - schema: *ref_1 + schema: *ref_2 originalParameter: - - ! &ref_32 - schema: *ref_1 - groupedBy: ! &ref_6 - schema: *ref_5 + - ! &ref_36 + schema: *ref_2 + groupedBy: ! &ref_7 + schema: *ref_6 implementation: Method language: ! default: @@ -264,11 +283,11 @@ schemas: ! description: Sets the maximum number of items to return in the response. protocol: ! {} - ! - schema: *ref_3 + schema: *ref_4 originalParameter: - - ! &ref_33 - schema: *ref_3 - groupedBy: *ref_6 + - ! &ref_37 + schema: *ref_4 + groupedBy: *ref_7 implementation: Method language: ! default: @@ -291,16 +310,16 @@ schemas: ! name: PagingGetOdataMultiplePagesOptions description: Parameter group protocol: ! {} - - ! &ref_7 + - ! &ref_8 type: group properties: - ! - schema: *ref_1 + schema: *ref_2 originalParameter: - - ! &ref_36 - schema: *ref_1 - groupedBy: ! &ref_8 - schema: *ref_7 + - ! &ref_40 + schema: *ref_2 + groupedBy: ! &ref_9 + schema: *ref_8 implementation: Method required: true language: ! @@ -324,11 +343,11 @@ schemas: ! description: Sets the maximum number of items to return in the response. protocol: ! {} - ! - schema: *ref_1 + schema: *ref_2 originalParameter: - - ! &ref_37 - schema: *ref_1 - groupedBy: *ref_8 + - ! &ref_41 + schema: *ref_2 + groupedBy: *ref_9 implementation: Method required: true language: ! @@ -347,11 +366,11 @@ schemas: ! description: Offset of return value protocol: ! {} - ! - schema: *ref_3 + schema: *ref_4 originalParameter: - - ! &ref_38 - schema: *ref_3 - groupedBy: *ref_8 + - ! &ref_42 + schema: *ref_4 + groupedBy: *ref_9 implementation: Method language: ! default: @@ -374,16 +393,16 @@ schemas: ! name: PagingGetMultiplePagesWithOffsetOptions description: Parameter group protocol: ! {} - - ! &ref_10 + - ! &ref_11 type: group properties: - ! - schema: *ref_9 + schema: *ref_10 originalParameter: - - ! &ref_46 - schema: *ref_9 - groupedBy: ! &ref_11 - schema: *ref_10 + - ! &ref_50 + schema: *ref_10 + groupedBy: ! &ref_12 + schema: *ref_11 implementation: Method required: true language: ! @@ -401,10 +420,10 @@ schemas: ! protocol: ! http: ! in: query - - ! &ref_48 - schema: *ref_9 - groupedBy: ! &ref_12 - schema: *ref_10 + - ! &ref_52 + schema: *ref_10 + groupedBy: ! &ref_13 + schema: *ref_11 implementation: Method required: true language: ! @@ -430,11 +449,11 @@ schemas: ! description: Sets the api version to use. protocol: ! {} - ! - schema: *ref_9 + schema: *ref_10 originalParameter: - - ! &ref_47 - schema: *ref_9 - groupedBy: *ref_11 + - ! &ref_51 + schema: *ref_10 + groupedBy: *ref_12 implementation: Method required: true language: ! @@ -445,9 +464,9 @@ schemas: ! protocol: ! http: ! in: path - - ! &ref_49 - schema: *ref_9 - groupedBy: *ref_12 + - ! &ref_53 + schema: *ref_10 + groupedBy: *ref_13 implementation: Method required: true language: ! @@ -472,16 +491,16 @@ schemas: ! name: CustomParameterGroup description: Parameter group protocol: ! {} - - ! &ref_13 + - ! &ref_14 type: group properties: - ! - schema: *ref_1 + schema: *ref_2 originalParameter: - - ! &ref_52 - schema: *ref_1 - groupedBy: ! &ref_14 - schema: *ref_13 + - ! &ref_56 + schema: *ref_2 + groupedBy: ! &ref_15 + schema: *ref_14 implementation: Method language: ! default: @@ -504,11 +523,11 @@ schemas: ! description: Sets the maximum number of items to return in the response. protocol: ! {} - ! - schema: *ref_3 + schema: *ref_4 originalParameter: - - ! &ref_53 - schema: *ref_3 - groupedBy: *ref_14 + - ! &ref_57 + schema: *ref_4 + groupedBy: *ref_15 implementation: Method language: ! default: @@ -532,33 +551,33 @@ schemas: ! description: Parameter group protocol: ! {} objects: - - ! &ref_27 + - ! &ref_28 type: object apiVersions: - ! version: 1.0.0 properties: - ! - schema: ! &ref_23 + schema: ! &ref_24 type: array apiVersions: - ! version: 1.0.0 - elementType: ! &ref_18 + elementType: ! &ref_19 type: object apiVersions: - ! version: 1.0.0 properties: - ! - schema: ! &ref_19 + schema: ! &ref_20 type: object apiVersions: - ! version: 1.0.0 properties: - ! - schema: *ref_15 + schema: *ref_16 serializedName: id language: ! default: @@ -566,7 +585,7 @@ schemas: ! description: '' protocol: ! {} - ! - schema: *ref_16 + schema: *ref_17 serializedName: name language: ! default: @@ -614,7 +633,7 @@ schemas: ! description: '' protocol: ! {} - ! - schema: *ref_17 + schema: *ref_18 serializedName: nextLink language: ! default: @@ -631,21 +650,21 @@ schemas: ! description: '' namespace: '' protocol: ! {} - - *ref_18 - *ref_19 - - ! &ref_28 + - *ref_20 + - ! &ref_29 type: object apiVersions: - ! version: 1.0.0 properties: - ! - schema: ! &ref_24 + schema: ! &ref_25 type: array apiVersions: - ! version: 1.0.0 - elementType: *ref_18 + elementType: *ref_19 language: ! default: name: ProductResultValues @@ -658,7 +677,7 @@ schemas: ! description: '' protocol: ! {} - ! - schema: *ref_20 + schema: *ref_21 serializedName: nextLink language: ! default: @@ -675,19 +694,19 @@ schemas: ! description: '' namespace: '' protocol: ! {} - - ! &ref_35 + - ! &ref_39 type: object apiVersions: - ! version: 1.0.0 properties: - ! - schema: ! &ref_25 + schema: ! &ref_26 type: array apiVersions: - ! version: 1.0.0 - elementType: *ref_18 + elementType: *ref_19 language: ! default: name: OdataProductResultValues @@ -700,7 +719,7 @@ schemas: ! description: '' protocol: ! {} - ! - schema: *ref_21 + schema: *ref_22 serializedName: odata.nextLink language: ! default: @@ -724,7 +743,7 @@ schemas: ! version: 1.0.0 properties: - ! - schema: *ref_22 + schema: *ref_23 serializedName: status language: ! default: @@ -738,11 +757,11 @@ schemas: ! namespace: '' protocol: ! {} arrays: - - *ref_23 - *ref_24 - *ref_25 + - *ref_26 globalParameters: -- ! &ref_26 +- ! &ref_27 schema: *ref_0 clientDefaultValue: 'http://localhost:3000' implementation: Client @@ -767,7 +786,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -782,7 +801,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_27 + schema: *ref_28 language: ! default: name: '' @@ -819,7 +838,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -834,7 +853,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -873,7 +892,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -888,7 +907,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -927,9 +946,9 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 - - ! &ref_31 - schema: *ref_9 + - *ref_27 + - ! &ref_32 + schema: *ref_10 implementation: Method language: ! default: @@ -939,14 +958,14 @@ operationGroups: protocol: ! http: ! in: header - - *ref_29 - *ref_30 + - *ref_31 requests: - ! parameters: - - *ref_4 + - *ref_5 signatureParameters: - - *ref_4 + - *ref_5 language: ! default: name: '' @@ -957,10 +976,10 @@ operationGroups: method: get uri: '{$host}' signatureParameters: - - *ref_31 + - *ref_32 responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -999,9 +1018,158 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 - ! &ref_34 - schema: *ref_9 + schema: *ref_2 + implementation: Method + required: true + language: ! + default: + name: requiredQueryParameter + description: A required integer query parameter. Put in value '100' to pass test. + serializedName: requiredQueryParameter + protocol: ! + http: ! + in: query + - ! + schema: *ref_33 + implementation: Method + required: true + language: ! + default: + name: queryConstant + description: A constant. Must be True and will be passed as a query parameter to nextOperationWithQueryParams + serializedName: queryConstant + protocol: ! + http: ! + in: query + requests: + - ! + language: ! + default: + name: '' + description: '' + protocol: ! + http: ! + path: /paging/multiple/getWithQueryParams + method: get + uri: '{$host}' + signatureParameters: + - *ref_34 + responses: + - ! + schema: *ref_29 + language: ! + default: + name: '' + description: '' + protocol: ! + http: ! + knownMediaType: json + mediaTypes: + - application/json + statusCodes: + - '200' + exceptions: + - ! + language: ! + default: + name: '' + description: '' + protocol: ! + http: ! + statusCodes: + - default + extensions: + x-ms-pageable: + itemName: values + nextLinkName: nextLink + operationName: Paging_nextOperationWithQueryParams + language: ! + default: + name: GetWithQueryParams + description: A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult + paging: + group: Paging + itemName: values + member: NextOperationWithQueryParams + nextLinkName: nextLink + nextLinkOperation: ! &ref_35 + apiVersions: + - ! + version: 1.0.0 + parameters: + - *ref_27 + - ! + schema: *ref_33 + implementation: Method + required: true + language: ! + default: + name: queryConstant + description: A constant. Must be True + serializedName: queryConstant + protocol: ! + http: ! + in: query + requests: + - ! + language: ! + default: + name: '' + description: '' + protocol: ! + http: ! + path: /paging/multiple/nextOperationWithQueryParams + method: get + uri: '{$host}' + signatureParameters: [] + responses: + - ! + schema: *ref_29 + language: ! + default: + name: '' + description: '' + protocol: ! + http: ! + knownMediaType: json + mediaTypes: + - application/json + statusCodes: + - '200' + exceptions: + - ! + language: ! + default: + name: '' + description: '' + protocol: ! + http: ! + statusCodes: + - default + extensions: + x-ms-pageable: + itemName: values + nextLinkName: nextLink + language: ! + default: + name: NextOperationWithQueryParams + description: Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult + paging: + itemName: values + nextLinkName: nextLink + protocol: ! {} + protocol: ! {} + - *ref_35 + - ! + apiVersions: + - ! + version: 1.0.0 + parameters: + - *ref_27 + - ! &ref_38 + schema: *ref_10 implementation: Method language: ! default: @@ -1011,14 +1179,14 @@ operationGroups: protocol: ! http: ! in: header - - *ref_32 - - *ref_33 + - *ref_36 + - *ref_37 requests: - ! parameters: - - *ref_6 + - *ref_7 signatureParameters: - - *ref_6 + - *ref_7 language: ! default: name: '' @@ -1029,10 +1197,10 @@ operationGroups: method: get uri: '{$host}' signatureParameters: - - *ref_34 + - *ref_38 responses: - ! - schema: *ref_35 + schema: *ref_39 language: ! default: name: '' @@ -1071,9 +1239,9 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 - - ! &ref_39 - schema: *ref_9 + - *ref_27 + - ! &ref_43 + schema: *ref_10 implementation: Method language: ! default: @@ -1083,15 +1251,15 @@ operationGroups: protocol: ! http: ! in: header - - *ref_36 - - *ref_37 - - *ref_38 + - *ref_40 + - *ref_41 + - *ref_42 requests: - ! parameters: - - *ref_8 + - *ref_9 signatureParameters: - - *ref_8 + - *ref_9 language: ! default: name: '' @@ -1102,10 +1270,10 @@ operationGroups: method: get uri: '{$host}' signatureParameters: - - *ref_39 + - *ref_43 responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -1144,7 +1312,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -1159,7 +1327,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -1198,7 +1366,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -1213,7 +1381,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -1252,7 +1420,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -1267,7 +1435,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -1306,7 +1474,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -1321,7 +1489,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -1360,7 +1528,7 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 + - *ref_27 requests: - ! language: ! @@ -1375,7 +1543,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -1414,9 +1582,9 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 - - ! &ref_40 - schema: *ref_9 + - *ref_27 + - ! &ref_44 + schema: *ref_10 implementation: Method required: true language: ! @@ -1427,8 +1595,8 @@ operationGroups: protocol: ! http: ! in: query - - ! &ref_41 - schema: *ref_9 + - ! &ref_45 + schema: *ref_10 implementation: Method required: true language: ! @@ -1451,11 +1619,11 @@ operationGroups: method: get uri: '{$host}' signatureParameters: - - *ref_40 - - *ref_41 + - *ref_44 + - *ref_45 responses: - ! - schema: *ref_35 + schema: *ref_39 language: ! default: name: '' @@ -1491,14 +1659,14 @@ operationGroups: itemName: values member: NextFragment nextLinkName: odata.nextLink - nextLinkOperation: ! &ref_45 + nextLinkOperation: ! &ref_49 apiVersions: - ! version: 1.0.0 parameters: - - *ref_26 - - ! &ref_42 - schema: *ref_9 + - *ref_27 + - ! &ref_46 + schema: *ref_10 implementation: Method required: true language: ! @@ -1509,8 +1677,8 @@ operationGroups: protocol: ! http: ! in: query - - ! &ref_43 - schema: *ref_9 + - ! &ref_47 + schema: *ref_10 implementation: Method required: true language: ! @@ -1521,8 +1689,8 @@ operationGroups: protocol: ! http: ! in: path - - ! &ref_44 - schema: *ref_9 + - ! &ref_48 + schema: *ref_10 implementation: Method required: true extensions: @@ -1547,12 +1715,12 @@ operationGroups: method: get uri: '{$host}' signatureParameters: - - *ref_42 - - *ref_43 - - *ref_44 + - *ref_46 + - *ref_47 + - *ref_48 responses: - ! - schema: *ref_35 + schema: *ref_39 language: ! default: name: '' @@ -1588,7 +1756,7 @@ operationGroups: itemName: values member: NextFragment nextLinkName: odata.nextLink - nextLinkOperation: *ref_45 + nextLinkOperation: *ref_49 protocol: ! {} protocol: ! {} - ! @@ -1596,15 +1764,15 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 - - *ref_46 - - *ref_47 + - *ref_27 + - *ref_50 + - *ref_51 requests: - ! parameters: - - *ref_11 + - *ref_12 signatureParameters: - - *ref_11 + - *ref_12 language: ! default: name: '' @@ -1617,7 +1785,7 @@ operationGroups: signatureParameters: [] responses: - ! - schema: *ref_35 + schema: *ref_39 language: ! default: name: '' @@ -1653,16 +1821,16 @@ operationGroups: itemName: values member: NextFragmentWithGrouping nextLinkName: odata.nextLink - nextLinkOperation: ! &ref_51 + nextLinkOperation: ! &ref_55 apiVersions: - ! version: 1.0.0 parameters: - - *ref_26 - - *ref_48 - - *ref_49 - - ! &ref_50 - schema: *ref_9 + - *ref_27 + - *ref_52 + - *ref_53 + - ! &ref_54 + schema: *ref_10 implementation: Method required: true extensions: @@ -1678,9 +1846,9 @@ operationGroups: requests: - ! parameters: - - *ref_12 + - *ref_13 signatureParameters: - - *ref_12 + - *ref_13 language: ! default: name: '' @@ -1691,10 +1859,10 @@ operationGroups: method: get uri: '{$host}' signatureParameters: - - *ref_50 + - *ref_54 responses: - ! - schema: *ref_35 + schema: *ref_39 language: ! default: name: '' @@ -1730,7 +1898,7 @@ operationGroups: itemName: values member: NextFragmentWithGrouping nextLinkName: odata.nextLink - nextLinkOperation: *ref_51 + nextLinkOperation: *ref_55 protocol: ! {} protocol: ! {} - ! @@ -1738,9 +1906,9 @@ operationGroups: - ! version: 1.0.0 parameters: - - *ref_26 - - ! &ref_54 - schema: *ref_9 + - *ref_27 + - ! &ref_58 + schema: *ref_10 implementation: Method language: ! default: @@ -1750,14 +1918,14 @@ operationGroups: protocol: ! http: ! in: header - - *ref_52 - - *ref_53 + - *ref_56 + - *ref_57 requests: - ! parameters: - - *ref_14 + - *ref_15 signatureParameters: - - *ref_14 + - *ref_15 language: ! default: name: '' @@ -1768,10 +1936,10 @@ operationGroups: method: post uri: '{$host}' signatureParameters: - - *ref_54 + - *ref_58 responses: - ! - schema: *ref_28 + schema: *ref_29 language: ! default: name: '' @@ -1806,8 +1974,8 @@ operationGroups: itemName: values nextLinkName: nextLink protocol: ! {} - - *ref_45 - - *ref_51 + - *ref_49 + - *ref_55 language: ! default: name: Paging diff --git a/test/TestServerProjects/paging/Generated/Operations/PagingClient.cs b/test/TestServerProjects/paging/Generated/Operations/PagingClient.cs index c27730b4..f0a07350 100644 --- a/test/TestServerProjects/paging/Generated/Operations/PagingClient.cs +++ b/test/TestServerProjects/paging/Generated/Operations/PagingClient.cs @@ -174,6 +174,76 @@ namespace paging return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); } + /// A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. + /// A required integer query parameter. Put in value '100' to pass test. + /// The cancellation token to use. + public virtual AsyncPageable GetWithQueryParamsAsync(int requiredQueryParameter, CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + var response = await RestClient.GetWithQueryParamsAsync(requiredQueryParameter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + var response = await RestClient.NextOperationWithQueryParamsAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. + /// A required integer query parameter. Put in value '100' to pass test. + /// The cancellation token to use. + public virtual Pageable GetWithQueryParams(int requiredQueryParameter, CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + var response = RestClient.GetWithQueryParams(requiredQueryParameter, cancellationToken); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + var response = RestClient.NextOperationWithQueryParams(cancellationToken); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + /// The cancellation token to use. + public virtual AsyncPageable NextOperationWithQueryParamsAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + var response = await RestClient.NextOperationWithQueryParamsAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + var response = await RestClient.NextOperationWithQueryParamsNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + /// The cancellation token to use. + public virtual Pageable NextOperationWithQueryParams(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + var response = RestClient.NextOperationWithQueryParams(cancellationToken); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + var response = RestClient.NextOperationWithQueryParamsNextPage(nextLink, cancellationToken); + return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse()); + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + /// A paging operation that includes a nextLink in odata format that has 10 pages. /// The String to use. /// Parameter group. diff --git a/test/TestServerProjects/paging/Generated/Operations/PagingRestClient.cs b/test/TestServerProjects/paging/Generated/Operations/PagingRestClient.cs index b8443444..a770e4ac 100644 --- a/test/TestServerProjects/paging/Generated/Operations/PagingRestClient.cs +++ b/test/TestServerProjects/paging/Generated/Operations/PagingRestClient.cs @@ -395,6 +395,183 @@ namespace paging } } + internal HttpMessage CreateGetWithQueryParamsRequest(int requiredQueryParameter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(host, false); + uri.AppendPath("/paging/multiple/getWithQueryParams", false); + uri.AppendQuery("requiredQueryParameter", requiredQueryParameter, true); + uri.AppendQuery("queryConstant", true, true); + request.Uri = uri; + return message; + } + + /// A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. + /// A required integer query parameter. Put in value '100' to pass test. + /// The cancellation token to use. + public async ValueTask> GetWithQueryParamsAsync(int requiredQueryParameter, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("PagingClient.GetWithQueryParams"); + scope.Start(); + try + { + using var message = CreateGetWithQueryParamsRequest(requiredQueryParameter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ProductResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + value = ProductResult.DeserializeProductResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. + /// A required integer query parameter. Put in value '100' to pass test. + /// The cancellation token to use. + public Response GetWithQueryParams(int requiredQueryParameter, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("PagingClient.GetWithQueryParams"); + scope.Start(); + try + { + using var message = CreateGetWithQueryParamsRequest(requiredQueryParameter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ProductResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + value = ProductResult.DeserializeProductResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateNextOperationWithQueryParamsRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(host, false); + uri.AppendPath("/paging/multiple/nextOperationWithQueryParams", false); + uri.AppendQuery("queryConstant", true, true); + request.Uri = uri; + return message; + } + + /// Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + /// The cancellation token to use. + public async ValueTask> NextOperationWithQueryParamsAsync(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams"); + scope.Start(); + try + { + using var message = CreateNextOperationWithQueryParamsRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ProductResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + value = ProductResult.DeserializeProductResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + /// The cancellation token to use. + public Response NextOperationWithQueryParams(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams"); + scope.Start(); + try + { + using var message = CreateNextOperationWithQueryParamsRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ProductResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + value = ProductResult.DeserializeProductResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + internal HttpMessage CreateGetOdataMultiplePagesRequest(string clientRequestId, PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions) { var message = _pipeline.CreateMessage(); @@ -1970,6 +2147,104 @@ namespace paging } } + internal HttpMessage CreateNextOperationWithQueryParamsNextPageRequest(string nextLink) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(host, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + return message; + } + + /// Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + /// The URL to the next page of results. + /// The cancellation token to use. + public async ValueTask> NextOperationWithQueryParamsNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams"); + scope.Start(); + try + { + using var message = CreateNextOperationWithQueryParamsNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ProductResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + value = ProductResult.DeserializeProductResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. + /// The URL to the next page of results. + /// The cancellation token to use. + public Response NextOperationWithQueryParamsNextPage(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams"); + scope.Start(); + try + { + using var message = CreateNextOperationWithQueryParamsNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ProductResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + value = ProductResult.DeserializeProductResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + internal HttpMessage CreateGetOdataMultiplePagesNextPageRequest(string nextLink, string clientRequestId, PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions) { var message = _pipeline.CreateMessage();