This commit is contained in:
Tizian.Breuch
2025-07-31 15:39:18 +02:00
parent ad7bfeaa40
commit 2f16e79a24

View File

@@ -2,13 +2,15 @@
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System; // Für Guid.NewGuid()
using Webshop.Application.DTOs; // Allgemeine DTOs wie AdminProductDto, ProductDto, SupplierDto
using System;
using System.Collections.Generic;
using Webshop.Application.DTOs;
using Webshop.Application.DTOs.Auth;
using Webshop.Application.DTOs.Categorys; // Korrekter Namespace
using Webshop.Application.DTOs.Categories;
using Webshop.Application.DTOs.Categorys;
using Webshop.Application.DTOs.Customers;
using Webshop.Application.DTOs.Discounts;
using Webshop.Application.DTOs.Email; // Für ResendEmailConfirmationRequestDto
using Webshop.Application.DTOs.Email;
using Webshop.Application.DTOs.Orders;
using Webshop.Application.DTOs.Payments;
using Webshop.Application.DTOs.Products;
@@ -69,22 +71,45 @@ namespace Webshop.Api.SwaggerFilters
["userName"] = new OpenApiString("user@example.com"),
["roles"] = new OpenApiArray { new OpenApiString("Customer") },
["createdDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
["emailConfirmed"] = new OpenApiBoolean(true)
["emailConfirmed"] = new OpenApiBoolean(true),
["lastActive"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
["phoneNumber"] = new OpenApiString("+491701234567"),
["firstName"] = new OpenApiString("Max"),
["lastName"] = new OpenApiString("Mustermann"),
["defaultShippingAddressId"] = new OpenApiNull(),
["defaultBillingAddressId"] = new OpenApiNull()
};
}
else if (type == typeof(ResendEmailConfirmationRequestDto)) // DTO verschoben nach Application/DTOs/Email
else if (type == typeof(ResendEmailConfirmationRequestDto))
{
schema.Example = new OpenApiObject
{
["email"] = new OpenApiString("unconfirmed.user@example.com")
};
}
else if (type == typeof(ChangePasswordRequestDto))
{
schema.Example = new OpenApiObject
{
["oldPassword"] = new OpenApiString("SecureCustomerPass123!"),
["newPassword"] = new OpenApiString("NewSecurePass456!"),
["confirmNewPassword"] = new OpenApiString("NewSecurePass456!")
};
}
else if (type == typeof(ChangeEmailRequestDto))
{
schema.Example = new OpenApiObject
{
["newEmail"] = new OpenApiString($"new.email.{uniqueId}@example.com"),
["currentPassword"] = new OpenApiString("SecureCustomerPass123!")
};
}
// --- Produkte & Lieferanten ---
else if (type == typeof(ProductDto))
{
schema.Example = new OpenApiObject
{
["id"] = new OpenApiString(Guid.Empty.ToString()),
["id"] = new OpenApiString(Guid.NewGuid().ToString()),
["name"] = new OpenApiString($"Public Produkt Beispiel {uniqueId}"),
["description"] = new OpenApiString("Eine kurze Beschreibung für das öffentliche Produkt."),
["sku"] = new OpenApiString($"PUB-PROD-{uniqueId}"),
@@ -92,7 +117,23 @@ namespace Webshop.Api.SwaggerFilters
["isActive"] = new OpenApiBoolean(true),
["isInStock"] = new OpenApiBoolean(true),
["stockQuantity"] = new OpenApiInteger(100),
["imageUrl"] = new OpenApiString("https://example.com/images/public_prod.jpg")
["imageUrl"] = new OpenApiString("https://example.com/images/public_prod.jpg"),
["slug"] = new OpenApiString($"public-produkt-beispiel-{uniqueId}"),
["categories"] = new OpenApiArray
{
new OpenApiObject
{
["id"] = new OpenApiString(Guid.NewGuid().ToString()),
["name"] = new OpenApiString("Hauptkategorie"),
["slug"] = new OpenApiString("hauptkategorie")
},
new OpenApiObject
{
["id"] = new OpenApiString(Guid.NewGuid().ToString()),
["name"] = new OpenApiString("Unterkategorie"),
["slug"] = new OpenApiString("unterkategorie")
}
}
};
}
else if (type == typeof(AdminProductDto))
@@ -114,7 +155,12 @@ namespace Webshop.Api.SwaggerFilters
["createdDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
["lastModifiedDate"] = new OpenApiNull(),
["supplierId"] = new OpenApiNull(),
["purchasePrice"] = new OpenApiDouble(80.00)
["purchasePrice"] = new OpenApiDouble(80.00),
["categoryIds"] = new OpenApiArray
{
new OpenApiString("EXISTING_CATEGORY_ID_1"),
new OpenApiString("EXISTING_CATEGORY_ID_2")
}
};
}
else if (type == typeof(SupplierDto))