Open abhalesd opened 2 years ago
Did you follow the "getting started" guide? It explains what to do: https://joukevandermaas.github.io/saule/content/1-getting-started.html
Hi, Thanks for replying. I have followed most of the instructions.
public class BuidlingApiResources : ApiResource
{
BuidlingApiResources() {
Attribute(nameof(BuildingDto.CompanyCodeId));
Attribute(nameof(BuildingDto.CompanyCodeCode));
Attribute(nameof(BuildingDto.CompanyCodeName));
Attribute(nameof(BuildingDto.AdministrationType));
Attribute(nameof(BuildingDto.ManagementId));
Attribute(nameof(BuildingDto.ManagementIdNum));
Attribute(nameof(BuildingDto.EconomicUnitId));
Attribute(nameof(BuildingDto.EconomicUnitIdNum));
Attribute(nameof(BuildingDto.EconomicUnitName));
Attribute(nameof(BuildingDto.BuildingId));
}
}
Trying to use it like this
[HttpGet]
[Route("buildings")]
[Paginated(PerPage = 25, PageSizeLimit = 100)]
[ReturnsResource(typeof(BuidlingApiResources))]
public IHttpActionResult GetBuildings([FromUri] string apiKey)
{
var messages = new Messages();
if (string.IsNullOrWhiteSpace(apiKey))
{
messages.AddValidationError("The api key is missing.");
}
if (messages.HasErrors)
{
return ApiControllerTools.BadRequestWithErrors(this, messages);
}
var result = BtsService.GetBuildings(apiKey, messages);
if (messages.HasErrors)
{
return ApiControllerTools.BadRequestWithErrors(this, messages);
}
return Ok(result);
}
I believe the issue may be that you are returning IHttpActionResult
. I don't remember if that is supported or not. But if this is a new project I recommend using .net 6 with ASP core and not 4.x with ASP Web API.
I have added package reference of saule in my project. But I am not able to resolve this error occurring after that
Resource types must inherit from Saule.ApiResource
Can you please help me in resolving this?