-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump apidoctor from 1708be5 to 1916d8c (#2004) Add use import statements for PHP Snippets (#2000) Bump Microsoft.OpenApi.OData from 1.6.0 to 1.6.1 (#2007) Bump Microsoft.VisualStudio.Azure.Containers.Tools.Targets (#2008) Bump MSTest.TestFramework from 3.2.2 to 3.3.0 (#2009) Bump MSTest.TestFramework from 3.3.0 to 3.3.1 (#2011) Bump Microsoft.VisualStudio.Azure.Containers.Tools.Targets (#2010) Chore: change drop location (#2012)
- Loading branch information
Showing
11 changed files
with
142 additions
and
14 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
78 changes: 78 additions & 0 deletions
78
CodeSnippetsReflection.OpenAPI.Test/PhpImportGeneratorTests.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,78 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using CodeSnippetsReflection.OpenAPI.LanguageGenerators; | ||
using Xunit; | ||
|
||
namespace CodeSnippetsReflection.OpenAPI.Test; | ||
|
||
public class PhpImportTests : OpenApiSnippetGeneratorTestBase | ||
{ | ||
private readonly PhpGenerator _generator = new(); | ||
|
||
[Fact] | ||
public async Task GeneratesRequestBuilderImports() | ||
{ | ||
using var requestPayload = new HttpRequestMessage(HttpMethod.Get, $"{ServiceRootUrl}/me/calendar/events?$filter=startsWith(subject,'All')"); | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); | ||
var result = _generator.GenerateCodeSnippet(snippetModel); | ||
Assert.Contains("use Microsoft\\Graph\\GraphServiceClient;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Users\\Item\\Calendar\\Events\\EventsRequestBuilderGetRequestConfiguration;", result); | ||
} | ||
|
||
[Fact] | ||
public async Task GenerateModelImports(){ | ||
var bodyContent = @"{ | ||
""displayName"": ""New display name"" | ||
}"; | ||
using var requestPayload = new HttpRequestMessage(HttpMethod.Patch, $"{ServiceRootUrl}/applications/{{id}}") | ||
{ | ||
Content = new StringContent(bodyContent, Encoding.UTF8, "application/json") | ||
}; | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); | ||
var result = _generator.GenerateCodeSnippet(snippetModel); | ||
Assert.Contains("use Microsoft\\Graph\\GraphServiceClient;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models\\Application;", result); | ||
|
||
} | ||
[Fact] | ||
public async Task GenerateComplexModelImports(){ | ||
var bodyContent = @"{ | ||
""subject"": ""Annual review"", | ||
""body"": { | ||
""contentType"": ""HTML"", | ||
""content"": ""You should be proud!"" | ||
}, | ||
""toRecipients"": [ | ||
{ | ||
""emailAddress"": { | ||
""address"": ""rufus@contoso.com"" | ||
} | ||
} | ||
], | ||
""extensions"": [ | ||
{ | ||
""@odata.type"": ""microsoft.graph.openTypeExtension"", | ||
""extensionName"": ""Com.Contoso.Referral"", | ||
""companyName"": ""Wingtip Toys"", | ||
""expirationDate"": ""2015-12-30T11:00:00.000Z"", | ||
""dealValue"": 10000 | ||
} | ||
] | ||
}"; | ||
using var requestPayload = new HttpRequestMessage(HttpMethod.Post, $"{ServiceRootUrl}/me/messages/") | ||
{ | ||
Content = new StringContent(bodyContent, Encoding.UTF8, "application/json") | ||
}; | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); | ||
var result = _generator.GenerateCodeSnippet(snippetModel); | ||
Assert.Contains("use Microsoft\\Graph\\GraphServiceClient;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models\\Message;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models\\ItemBody;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models\\Recipient;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models\\EmailAddress;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models\\Extension;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models\\OpenTypeExtension;", result); | ||
} | ||
} |
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
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
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
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
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
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
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
Submodule apidoctor
updated
11 files
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 |
---|---|---|
|
@@ -151,3 +151,4 @@ extends: | |
parameters: | ||
directory: 'microsoft-graph-devx-api' | ||
repoName: ReleasePipelines | ||
dependsOn: ['Build'] |