API Explorer reserved DTO object names

Hello,
I’m using API Explorer for testing.
Are there some DTO object names to avoid in order to keep the API explorer functionality?
In the specific, I have a request that contains a DTO called “Function”, if I remove the request from the service API Explorer works otherwise I receive an http exception and the browser page is blank.

If possible I would like to avoid renaming the “Function” class.

Thank you.

Part of the DTO:

[Schema("rcs")]
[Alias("Functions")]
public class Function
{
	[PrimaryKey]
	[AutoIncrement]
	public int Id { get; set; }

	[Required]
	[StringLength(50)]
	[Index(Unique=true)]
	public string Code { get; set; }

	[Required]
	[ForeignKey(typeof(FunctionFamily))]
	public int FamilyId { get; set; }

...

}

The request:

public class RcsFunctionAdd : IReturn<int>
{
    public Function Entity { get; set; }
}

Service implementation:

    [Authenticate]
    [RequiresAnyPermission(FullPermission, AddPermission)]
    public RequestResult<int> Post(RcsFunctionAdd request)
    {
    	Manager mng = new Manager(this.Parameters);
    	int id = mng.Insert<Function>(request.Entity);
    	return new RequestResult<int>() { Value = id };
    }

Right, the Request DTO needs to have a flat structure, i.e. nested complex types are not supported in the UI form, although they can still be pasted in the JSON Form.

If it helps you can use the AutoMapping Utils to easily convert Request DTOs into different Types, e.g:

public RequestResult<int> Post(RcsFunctionAdd request)
{
    var entity = request.ConvertTo<Function>();
    int id = mng.Insert<Function>(entity);
    //...
}

My problem is that when I have the DTO named “Function” all the “/ui” doesn’t work. All the API are not working, not only those with the nested complex types. If I remove or simply rename the DTO “Function” the flat types have the ui working and the complexx types the blank page. With the “Function” DTO all the ui stop working.

Yeah you wont be able to use JavaScript keywords, existing types or override global symbols that exist in browsers. Function is a core type in JavaScript.

I will consider how to proceed. Unfortunately I have a lot of old code and I have to consider also backwards compatibility.
Thank you.

1 Like