Loading...
Loading...
Compare original and translation side by side
| Aspect | Details |
|---|---|
| Input | Context Store from ln-770 |
| Output | Swagger/OpenAPI configuration |
| Stacks | .NET (Swashbuckle), Python (FastAPI built-in) |
| 方面 | 详情 |
|---|---|
| 输入 | 来自ln-770的上下文存储 |
| 输出 | Swagger/OpenAPI配置 |
| 技术栈 | .NET(Swashbuckle)、Python(FastAPI内置) |
STACKPROJECT_ROOTAddSwaggerGenUseSwagger{ "status": "skipped" }STACKPROJECT_ROOTAddSwaggerGenUseSwagger{ "status": "skipped" }MCP ref: "Swashbuckle ASP.NET Core OpenAPI Swagger configuration"
Context7: /domaindrivendev/Swashbuckle.AspNetCoreMCP ref: "FastAPI OpenAPI documentation customization"
Context7: /tiangolo/fastapiMCP ref: "Swashbuckle ASP.NET Core OpenAPI Swagger configuration"
Context7: /domaindrivendev/Swashbuckle.AspNetCoreMCP ref: "FastAPI OpenAPI documentation customization"
Context7: /tiangolo/fastapi| Field | Description | Required |
|---|---|---|
| Title | API name | ✓ Yes |
| Version | API version (v1, v2) | ✓ Yes |
| Description | Brief description | Optional |
| Contact | Support contact | Optional |
| License | API license | Optional |
| 字段 | 描述 | 必填 |
|---|---|---|
| 标题 | API名称 | ✓ 是 |
| 版本 | API版本(v1、v2) | ✓ 是 |
| 描述 | 简要描述 | 可选 |
| 联系方式 | 支持联系方式 | 可选 |
| 许可证 | API许可证 | 可选 |
| Scheme | Use Case | OpenAPI Type |
|---|---|---|
| JWT Bearer (Recommended) | Token in Authorization header | |
| API Key | Key in header or query | |
| OAuth2 | Full OAuth2 flow | |
| None | Public API | No security |
| 方案 | 使用场景 | OpenAPI类型 |
|---|---|---|
| JWT Bearer(推荐) | 在Authorization头中携带Token | |
| API密钥 | 在Header或Query中携带密钥 | |
| OAuth2 | 完整OAuth2流程 | |
| 无 | 公开API | 无安全验证 |
| Feature | .NET | Python | Default |
|---|---|---|---|
| XML Comments | ✓ Supported | N/A | ✓ Enable |
| Response Examples | ✓ Manual | ✓ Pydantic | ✓ Enable |
| Request Validation | ✓ Annotations | ✓ Pydantic | ✓ Enable |
| Try It Out | ✓ Yes | ✓ Yes | ✓ Enable |
| 功能 | .NET | Python | 默认设置 |
|---|---|---|---|
| XML注释 | ✓ 支持 | 不适用 | ✓ 启用 |
| 响应示例 | ✓ 手动配置 | ✓ Pydantic | ✓ 启用 |
| 请求验证 | ✓ 注解 | ✓ Pydantic | ✓ 启用 |
| 在线调试 | ✓ 支持 | ✓ 支持 | ✓ 启用 |
| File | Purpose |
|---|---|
| Swagger service registration |
| Enable XML documentation |
Swashbuckle.AspNetCorebuilder.Services.AddSwaggerServices();
// ...
app.UseSwaggerServices();<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>| 文件 | 用途 |
|---|---|
| Swagger服务注册 |
| 启用XML文档 |
Swashbuckle.AspNetCorebuilder.Services.AddSwaggerServices();
// ...
app.UseSwaggerServices();<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>| File | Purpose |
|---|---|
| OpenAPI customization |
from core.openapi_config import custom_openapi
app.openapi = lambda: custom_openapi(app)| 文件 | 用途 |
|---|---|
| OpenAPI自定义配置 |
from core.openapi_config import custom_openapi
app.openapi = lambda: custom_openapi(app)dotnet build --no-restorepython -m py_compile core/openapi_config.py| Stack | URL |
|---|---|
| .NET | http://localhost:5000/swagger |
| Python | http://localhost:5000/docs |
| Python (ReDoc) | http://localhost:5000/redoc |
# .NET
curl http://localhost:5000/swagger/v1/swagger.json | jq .
# Python
curl http://localhost:5000/openapi.json | jq .dotnet build --no-restorepython -m py_compile core/openapi_config.py| 技术栈 | 地址 |
|---|---|
| .NET | http://localhost:5000/swagger |
| Python | http://localhost:5000/docs |
| Python(ReDoc) | http://localhost:5000/redoc |
# .NET
curl http://localhost:5000/swagger/v1/swagger.json | jq .
# Python
curl http://localhost:5000/openapi.json | jq .// Structure only - actual code generated via MCP ref
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using Bearer scheme",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT"
});// 仅结构展示 - 实际代码通过MCP参考生成
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using Bearer scheme",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT"
});undefined// 仅结构展示 - 实际代码通过MCP参考生成
from fastapi.security import HTTPBearer
security = HTTPBearer()
---{
"status": "success",
"files_created": [
"Extensions/SwaggerExtensions.cs"
],
"packages_added": [
"Swashbuckle.AspNetCore"
],
"registration_code": "builder.Services.AddSwaggerServices();",
"message": "Configured Swagger/OpenAPI documentation"
}{
"status": "success",
"files_created": [
"Extensions/SwaggerExtensions.cs"
],
"packages_added": [
"Swashbuckle.AspNetCore"
],
"registration_code": "builder.Services.AddSwaggerServices();",
"message": "Configured Swagger/OpenAPI documentation"
}