-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for basic async APIs (#46974)
* added support for basic async APIs * PR feedback * removed dependency on deprecated package
- Loading branch information
1 parent
9e4950e
commit ea5cb40
Showing
3 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 1 addition & 1 deletion
2
...ioning/Azure.Provisioning.CloudMachine/tests/Azure.Provisioning.CloudMachine.Tests.csproj
This file contains 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
67 changes: 67 additions & 0 deletions
67
sdk/provisioning/Azure.Provisioning.CloudMachine/tests/TdkTests.cs
This file contains 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,67 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#nullable enable | ||
|
||
using System; | ||
using System.ClientModel.TypeSpec; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.CloudMachine.Tests; | ||
|
||
public class TdkTests | ||
{ | ||
[Test] | ||
public void GenerateIAssistantService() | ||
{ | ||
MemoryStream stream = new(); | ||
TypeSpecWriter.WriteServer<IAssistantService>(stream); | ||
stream.Position = 0; | ||
|
||
BinaryData data = BinaryData.FromStream(stream); | ||
Assert.AreEqual(IAssistantServiceTsp, data.ToString()); | ||
} | ||
|
||
private static string IAssistantServiceTsp = | ||
""" | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
import "@azure-tools/typespec-client-generator-core"; | ||
@service({ | ||
title: "AssistantService", | ||
}) | ||
namespace Azure.CloudMachine.Tests; | ||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
using Azure.ClientGenerator.Core; | ||
@client interface AssistantServiceClient { | ||
@put @route("upload") Upload(@header contentType: "application/octet-stream", @body document: bytes) : { | ||
@statusCode statusCode: 200; | ||
@body response : void; | ||
}; | ||
@get @route("send") Send(@query message: string) : { | ||
@statusCode statusCode: 200; | ||
@body response : string; | ||
}; | ||
} | ||
"""; | ||
} | ||
|
||
internal interface IAssistantService | ||
{ | ||
[HttpPut] | ||
Task UploadAsync(HttpRequest document); | ||
Task<string> SendAsync([FromQuery] string message); | ||
} | ||
|
||
internal class FromQueryAttribute : Attribute { } | ||
internal class HttpPutAttribute : Attribute { } |