Skip to content

Commit

Permalink
Removed Swagger 2.0 specification and tests (#7047)
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 authored Apr 11, 2024
1 parent 3ead83c commit 565484c
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 598 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<None Update="__resources__\PetStore.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Remove="__resources__\Uber.json" />
<None Include="__resources__\Uber.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -55,45 +55,4 @@ public async Task QueryPets_Returns_Results(string caseName, string query)
Assert.NotNull(result);
Snapshot.Match(result, postFix: caseName, extension: ".json");
}


[Theory]
[InlineData("me", "query { me { firstName lastName email picture promoCode } }")]
[InlineData("getProducts", "query { products(longitude: 1, latitude: 1) { productId displayName } }")]
public async Task QueryUber_Returns_Results(string caseName, string query)
{
// Arrange
var httpClientFactoryMock = new Mock<IHttpClientFactory>();
var builder = new WebHostBuilder();
builder.ConfigureServices(services =>
{
services.AddRouting();
services.AddControllers();
});
builder.Configure(app =>
{
app.UseRouting();
app.UseEndpoints(e => e.MapControllers());
});
var openApiServer = new TestServer(builder);

httpClientFactoryMock.Setup(f => f.CreateClient(It.IsAny<string>()))
.Returns(() => openApiServer.CreateClient());

await openApiServer.Host.StartAsync();
var apiDocument = FileResource.Open("Uber.json");

var schema = await new ServiceCollection()
.AddSingleton(httpClientFactoryMock.Object)
.AddGraphQL()
.AddOpenApi("Uber", apiDocument)
.BuildRequestExecutorAsync();

// Act
var result = await schema.ExecuteAsync(QueryRequestBuilder.Create(query));

// Assert
Assert.NotNull(result);
Snapshot.Match(result, postFix: caseName, extension: ".json");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,4 @@ public async Task Simple_PetStore_V3_Generates_Correct_Schema()
_testOutputHelper.WriteLine(schema.ToString());
schema.MatchSnapshot();
}

[Fact]
public async Task Uber_Generates_Correct_SkimmedSchema()
{
// Arrange
await using var stream = File.Open(Combine("__resources__", "Uber.json"), FileMode.Open);
var wrapper = new OpenApiWrapper();
var document = new OpenApiStreamReader().Read(stream, out var diag);

// Act
var schema = wrapper.Wrap("PetStore", document);

// Assert
var sdl = SchemaFormatter.FormatAsString(schema);
_testOutputHelper.WriteLine(sdl);
Assert.NotNull(sdl);
Snapshot.Match(sdl, extension: ".graphql");
}
}
Loading

0 comments on commit 565484c

Please sign in to comment.