OpenAPI Validation error

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.’.

The API is hosted here: https://serviceproviderapi.azurewebsites.net/swagger-ui/

Setting attribute

[ApiMember(ParameterType = "path", IsRequired = true)]

should resolve validation error. If not, can you show declaration of ServiceProvider DTO for delete operation?

Thanks for your reply. But that did not resolve the error. Here is the error message:

{“schemaValidationMessages”:[{“level”:“error”,“domain”:“validation”,“keyword”:“type”,“message”:“instance type (boolean) does not match any allowed primitive type (allowed: [“array”])”,“schema”:{“loadingURI”:“http://json-schema.org/draft-04/schema#",“pointer”:"/definitions/stringArray"},“instance”:{“pointer”:"/definitions/DeleteServiceProviderRequestDto/properties/Id/required”}}]}

And here is the DTO as you requested:

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

[ApiMember(ParameterType = "path"]
1 Like

Thanks for the quick fix. I tried to get the pre-release 4.5.15 package for ServiceStack.Api.OpenApi but I am getting the following error in the output:
The V2 feed at ‘https://www.nuget.org/profiles/ServiceStack/FindPackagesById()?id=‘ServiceStack’’ returned an unexpected status code ‘404 Not Found’.

The pre-release packages are only available on MyGet.

Yes, I am trying to get it from MyGet. Attaching a screen shot of my IDE to make sure I am not missing anything.

It seems odd that the query is being returned from nuget.org for packages on MyGet. I’ve republished the packages to MyGet in case that was the issue.

If not can you paste a screenshot of your MyGet feed config to see if it matches: http://docs.servicestack.net/myget

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!

1 Like

This fixed the OpenAPI validation error. Thanks so much…You guys rock!!!