Skip to content
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
19 changes: 19 additions & 0 deletions docs/docs/integration/json-transcoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ builder.Services.AddMagicOnionJsonTranscodingSwagger();
builder.Services.AddSwaggerGen(options =>
{
// Reflect the XML documentation comments of the service definition in Swagger.
// To use this feature, you must enable the Generate XML Comments option in project options.
options.IncludeMagicOnionXmlComments(Path.Combine(AppContext.BaseDirectory, "JsonTranscodingSample.Shared.xml"));
});

Expand All @@ -50,3 +51,21 @@ app.Run();
```

![image](https://github.com/user-attachments/assets/a101cb00-c9ad-42b6-93d4-87c0d8d23773)



## Troubleshooting

If you encounter the following exception at runtime, adding `builder.Services.AddEndpointsApiExplorer();` can help resolve the issue.
```csharp
System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator': No constructor for type 'Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator' can be instantiated using services from the service container and default values.)
```


Reference
MSDN documentation for the usage of Swashbuckle.AspNetCore.Swagger used in MagicOnion.
https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-8.0&tabs=visual-studio

```csharp
builder.Services.AddEndpointsApiExplorer();
```
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ builder.Services.AddMagicOnionJsonTranscodingSwagger();
builder.Services.AddSwaggerGen(options =>
{
// Reflect the XML documentation comments of the service definition in Swagger.
// To use this feature, you must enable the Generate XML Comments option in project options.
options.IncludeMagicOnionXmlComments(Path.Combine(AppContext.BaseDirectory, "JsonTranscodingSample.Shared.xml"));
});

Expand All @@ -52,3 +53,21 @@ app.Run();
```

![image](https://github.com/user-attachments/assets/a101cb00-c9ad-42b6-93d4-87c0d8d23773)



## トラブルシューティング

実行時に以下のような例外が発生した場合、`builder.Services.AddEndpointsApiExplorer();` を追加することで解決できます。
```csharp
System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator': No constructor for type 'Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator' can be instantiated using services from the service container and default values.)
```


参考
MagicOnion で使用されている Swashbuckle.AspNetCore.Swagger の使用法が記録された MSDN ドキュメントです。
https://learn.microsoft.com/ja-jp/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-8.0&tabs=visual-studio

```csharp
builder.Services.AddEndpointsApiExplorer();
```