Skip to content

Commit c7fe719

Browse files
committed
swagger
1 parent 4634951 commit c7fe719

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/Built.Grpcc.SwaggerGen/Swagger/SwaggerDefinitionBuilder.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public byte[] BuildSwaggerJson()
9292
parameters = parameters
9393
};
9494

95-
doc.paths.Add("/" + item.ToString(), new PathItem { post = operation }); // everything post.
95+
doc.paths.Add("/" + item.Service.FullName + "/" + item.Name, new PathItem { post = operation }); // everything post.
9696
}
9797

9898
using (var ms = new MemoryStream())
@@ -343,7 +343,9 @@ private static Type GetCollectionType(Type type)
343343
|| genTypeDef == typeof(IList<>)
344344
|| genTypeDef == typeof(List<>)
345345
|| genTypeDef == typeof(IReadOnlyCollection<>)
346-
|| genTypeDef == typeof(IReadOnlyList<>))
346+
|| genTypeDef == typeof(IReadOnlyList<>)
347+
|| genTypeDef == typeof(Google.Protobuf.Collections.RepeatedField<>)
348+
)
347349
{
348350
return genTypeDef.GetGenericArguments()[0];
349351
}

src/samples/OcelotGateway/Examples.OcelotGateway.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<PackageReference Include="Built.Extensions.Configuration.Yaml" Version="1.0.0" />
2727
<PackageReference Include="Microsoft.AspNetCore.App" />
2828
<PackageReference Include="Ocelot" Version="12.0.0" />
29+
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
2930
</ItemGroup>
3031

3132
<ItemGroup>

src/samples/OcelotGateway/Startup.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public Startup(IConfiguration configuration)
2424
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
2525
public void ConfigureServices(IServiceCollection services)
2626
{
27+
services.AddMvc();
28+
services.AddSwaggerGen(c =>
29+
{
30+
c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info { Title = "My API", Version = "v1" });
31+
});
2732
services.AddOcelot(Configuration).AddGrpcHttpGateway(Configuration);
2833
}
2934

@@ -66,7 +71,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
6671
app.UseDeveloperExceptionPage();
6772
}
6873
app.Map("/srv", HandleHome);
69-
app.Map("/swagger", HandleSwagger);
74+
app.Map("/swagger/v1/swagger.json", HandleSwagger);
75+
// Enable middleware to serve generated Swagger as a JSON endpoint.
76+
app.UseSwagger();
77+
78+
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
79+
// specifying the Swagger JSON endpoint.
80+
app.UseSwaggerUI(c =>
81+
{
82+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
83+
});
7084
//ServiceLocator.Instance = app.ApplicationServices;
7185
app.UseOcelot(config =>
7286
{

0 commit comments

Comments
 (0)