36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Kreta.Core;
|
|
using Kreta.Core.Domain;
|
|
using Kreta.Core.Enum;
|
|
using Kreta.Naplo.Domain.V3.Interfaces;
|
|
using Kreta.Naplo.Dto.V3.Exception;
|
|
using Swashbuckle.Examples;
|
|
|
|
namespace Kreta.Naplo.WebApi.V3.Documentation
|
|
{
|
|
/// <summary>
|
|
/// Author: DevKornél Created On: 2019.05.
|
|
/// </summary>
|
|
public class ValidaciosHibaExample<TModel, TSameModel> : NaploExceptionResponseDto, IExamplesProvider where TModel : class, IModelValidacio<TSameModel>, new() where TSameModel : class
|
|
{
|
|
public ValidaciosHibaExample() : base(BlExceptionType.ModelValidacio, BlExceptionType.ModelValidacio.ToDisplayName())
|
|
{
|
|
}
|
|
|
|
public ValidaciosHibaExample(IEnumerable<DetailedErrorItem> errorList)
|
|
: base(BlExceptionType.ModelValidacio, BlExceptionType.ModelValidacio.ToDisplayName(), errorList.ToList())
|
|
{
|
|
}
|
|
|
|
public object GetExamples()
|
|
{
|
|
List<DetailedErrorItem> example = new List<DetailedErrorItem>();
|
|
int index = 0;
|
|
|
|
new List<string>(new TModel().ModelValidaciok.Values).ForEach(x => example.Add(new DetailedErrorItem($"custom_{++index}", x, BlExceptionType.ModelValidacio)));
|
|
|
|
return new ValidaciosHibaExample<TModel, TSameModel>(example);
|
|
}
|
|
}
|
|
}
|