Skip to content
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

Remove Swagger 2.0 specification and tests #7047

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
Loading