AutoQuery partial documentation sample

the minimal default AutoQuery implementation

[Route("/projections/countries")]
public class FindCountries : QueryBase<Country>
{
	public string NameStartsWith { get; set; }
}

produces a partial documentation page

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"id":0,"name":"String","displayName":"String"}

the correct/real output should be

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Offset":0,"Total":0,"Results":[{"id":0,"name":"String","displayName":"String"}],"Meta":{"String":"String"},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}

In order to get that output and to have it work through soap/wsdl, I have to do the following customization

[Route("/projections/countries2")]
[DataContract()]
public class FindCountriesSoap : IQuery<Country>, IReturn<FindCountriesSoapResponse>
{
	[DataMember]
	public string NameStartsWith { get; set; }

	[DataMember(Order = 1)]
	public virtual int? Skip { get; set; }

	[DataMember(Order = 2)]
	public virtual int? Take { get; set; }

	[DataMember(Order = 3)]
	public virtual string OrderBy { get; set; }

	[DataMember(Order = 4)]
	public virtual string OrderByDesc { get; set; }

	[DataMember(Order = 5)]
	public virtual string Include { get; set; }

	[DataMember(Order = 6)]
	public virtual Dictionary<string, string> Meta { get; set; }
}


[DataContract()]
public class FindCountriesSoapResponse : QueryResponse<Country>
{
	public static FindCountriesSoapResponse Create(QueryResponse<Country> queryResponse)
	{
		var obj = new FindCountriesSoapResponse();
		obj.Meta = queryResponse.Meta;
		obj.Offset = queryResponse.Offset;
		obj.Total = queryResponse.Total;
		obj.Results = queryResponse.Results;
		obj.ResponseStatus = queryResponse.ResponseStatus;
		return obj;
	}
}

plus adding a dedicated service

public class CountryServices : Service
{
	public IAutoQuery AutoQuery { get; set; }

	//Override with custom implementation
	public object Any(FindCountriesSoap request)
	{
		var q = AutoQuery.CreateQuery(request, Request.GetRequestParams());
		var queryResponse = AutoQuery.Execute(request, q);
		return FindCountriesSoapResponse.Create(queryResponse);
	}
}

I could understand the customozation for the soap/wsdl support, but at least the documentation should reflect the real output with no need to customize the mimimal implemtation (RequestDTO only)

in both case the documentation page does not describe the ResponseStatus type: it simply list it within the
QueryResponse type, but the type description is missing

QueryResponse<T> Parameters:
NAME	PARAMETER	DATA TYPE	REQUIRED	DESCRIPTION
Offset	form	int	No	
Total	form	int	No	
Results	form	List<T>	No	
Meta	form	Dictionary<string, string>	No	
ResponseStatus	form	ResponseStatus	No

If you want to use them in SOAP, you’d need to ensure all DTO’s are annotated with DataContract attributes.

We’re not emitting the built-in ResponseStatus and ResponseError DTO’s by design to avoid signal/noise ratio of duplicated DTO’s of built-in types. But I’ve added an optionwhere you can show ResponseStatus DTO’s in metadata pages, in AppHost.Configure() with:

this.GetPlugin<MetadataFeature>().ShowResponseStatusInMetadataPages = true;

It should now also include the full response of generic type responses.

Theses changes are available in v4.0.51 that’s now available on MyGet.

Ok thanks, I’ll check it our your myget for the fixing.
About Soap, I’m aware about the convetions so I implemented within my sample.
The problem is the built-in QueryBase is not using DataContract indeed.

It would then turn every sub-class DTO into opt-in serialization and force needing [DataMember] attributes for every property that you’d want serialized - causing a lot more issues then the default behavior.