Metadata when DTO implements IReturn<List<T>>

I’ve found that with SS 4.5.8 I can’t have a request DTO implementing IReturn<List<T>> and have the metadata page correctly show the metadata. If I change the request DTO to return a purpose made response DTO which contains a single property as List<T> then the metadata displays correctly.

For example - to demonstrate the issue - I have a model like so:

public class Pet
{
    virtual public int? PetId { get; set; }
    virtual public string Name { get; set; }
}

I have a request DTO:

public class PetsGETManyRequest : IReturn<List<Pet>>
{
}

And a service:

public class PetServices : Service
{
    public List<Pet> Get(PetsGETManyRequest request)
    {
        List<Pet> pets = new List<Pet>();

        return pets;
    }
}

The metadata page looks then like this:

However - If I change my request DTO to be this:

public class PetsGETManyRequest : IReturn<PetsGETResponse>
{
}

And introduce a new class to hold the response:

public class PetsGETResponse
{
    virtual public List<Pet> Pets { get; set; }
}

And alter my service:

public class PetServices : Service
{
    public PetsGETResponse Get(PetsGETManyRequest request)
    {
        List<Pet> pets = new List<Pet>();

        return new PetsGETResponse() { Pets = pets };
    }
}

The metadata page now looks correct - the class and fields of each class with their respective names, data types, descriptions et cetera are shown :

Is there something I am doing wrong?

Ideally I’d like to be able to avoid having to create purpose made response DTO’s which are just a single property when returning List<T>.

Metadata plugin does not handle List response in special way as Swagger or OpenApi plugins do that’s why you do not see data types description on the page. We’ll look if this support can be added for metadata pages too.

Thanks, xplicit, for your attention to this.

Metadata plugin does not handle List response in special way as Swagger or OpenApi plugins do

If I add the OpenAPI plugin, then the Swagger UI also doesn’t show the response as expected with IReturn<List<Pet>>. I’m not sure if that’s a Swagger UI issue or an OpenAPI issue - but it’d be great if both the metadata plugin and the OpenAPI plugin documented the expected response to be consistent with non-List return types.

We’re a significant way through building a REST API using SS to bolt onto our ERP product and consistency across our several hundred (and growing!) routes for the metadata is highly desirable. Whilst it might seem trivial, it’s going to be a big deal for us and consumers of our API when we publish.

Thanks to you and the rest of the ServiceStack team for all your efforts - I’m loving the framework and philosophy behind it! Best money I ever spent :smile:

Mike

What do you see in Swagger UI when open POST operation? I see this for IReturn<List<Pets>> example

and this model

I can’t say right now why Swagger UI calls types “Inline model” while all types have their own names in swagger.json (I’ll look on it too), but at least response classes should be shown in swagger.

I see the same as you posted. And that puzzled me, so I looked at my GET in Swagger again and it too is showing the response the same as the POST now. I’m sure it was just showing me object as the response type before. I’ll put that down to tired eyes for now!

The naming response types is fixed for Swagger UI in OpenApi plugin via this commit and this change is avalable from v4.5.9 on MyGet

For metadata page I’m looking what can be done.

That’s awesome - thanks!