I am trying to use my API (build with ServiceStack) with PowerApps and Microsoft Flow which require it to be an OpenAPI. However, It throws an error that the path template parameters must be defined in path parameters collection. It seems to fix the error, if I have a route like this [Route("/ServiceProvider/{Id}", “PUT”, Summary = “Update a ServiceProvider”)]
I should annotate the “id” parameter in the DTO as follows: [ApiMember(ParameterType = “path”)] public int Id { get; set; }
However, when I do that I get another error: Failed PowerApps Custom API creation. Error Details: The request failed with error: ‘Parsing error(s): JSON is valid against more than one schema from ‘oneOf’. No valid schemas. Path ‘paths./{connectionId}/ServiceProvider/{Id}.put.parameters[1]’, line 218, position 11.’.
namespace ServiceProvider.API.ServiceDto.ServiceProvider
{
[Api("CRUD for ServiceProviders")]
[Route("/ServiceProvider/{Id}", "Delete", Summary = "Delete a ServiceProvider by Id")]
[ApiResponse(HttpStatusCode.InternalServerError, "Something went wrong. Please contact the support team")]
public class DeleteServiceProviderRequestDto : IReturn<DeleteServiceProviderReponseDto>
{
[ApiMember(ParameterType = "path", IsRequired = true)]
public int Id { get; set; }
[ApiMember(DataType = "boolean", Description = "If this flag is set to true all associations with ServiceProviderTeam or other tables will be removed and the ServiceProvider will be deleted.")]
public bool ForceDelete { get; set; }
}
public class DeleteServiceProviderReponseDto : IHasResponseStatus
{
public ResponseStatus ResponseStatus { get; set; }
}
}
Removed description of “ForceDelete” ApiMember to make it easy to read.
using System.Net;
using ServiceStack;
namespace ServiceProvider.API.ServiceDto.ServiceProvider
{
[Api("CRUD for ServiceProviders")]
[Route("/ServiceProvider/{Id}", "Delete", Summary = "Delete a ServiceProvider by Id")]
[ApiResponse(HttpStatusCode.InternalServerError, "Something went wrong. Please contact the support team")]
public class DeleteServiceProviderRequestDto : IReturn<DeleteServiceProviderReponseDto>
{
[ApiMember(ParameterType = "path", IsRequired = true)]
public int Id { get; set; }
[ApiMember(DataType = "boolean")]
public bool ForceDelete { get; set; }
}
public class DeleteServiceProviderReponseDto : IHasResponseStatus
{
public ResponseStatus ResponseStatus { get; set; }
}
}
Validation error message for required properties in schema is fixed via this commit which is available on MyGet
It is not necessary anymore to add IsRequired=true for parameter type path since this commit. Now you can annotate properties just with
My bad…Even though I added the MyGet package source, I had the nuget.org one also checked and for some reason it was defaulting to that to look for the packages.It downloaded the package now. Thanks for your help!