Showing model/class members in help page

26 views
Skip to first unread message

Everton Macedo

unread,
Feb 11, 2015, 2:46:41 AM2/11/15
to jay...@googlegroups.com
Hi Atif.

Is there a way to populate the model of the request parameters in the help page for frontend developers?
Current: 

It would be nice to have a expanded JsonObject beside of "null". Maybe there is a annotation for that, which I don't know :)

Regards.
Everton

Atif Aziz

unread,
Feb 16, 2015, 5:31:15 PM2/16/15
to jay...@googlegroups.com
No, there is no annotation for that, I'm afraid. You could, however, take the sources of JsonRpcTester and build on top to add the functionality you need. You could, for example, add an annotation that provides a template JSON for a parameter to supplied when testing.

- Atif

--
You received this message because you are subscribed to the Google Groups "Jayrock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jayrock+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Everton Macedo

unread,
Feb 17, 2015, 7:15:19 AM2/17/15
to jay...@googlegroups.com
Hi Atif.
It looks like a project :)
I'll take a look at the ParameterBuilder and maybe extend the properties...
I have to pass the parameter details somehow to the ASP page...

Parameter[] parameters = method.GetParameters();

if (parameters.Length == 0)
{
sb.Append("/* void */");
}
else
{
foreach (Parameter parameter in parameters)
{
if (parameter.Position > 0)
sb.Append(", ");


sb.Append('"').Append(parameter.Name).Append("\" : null");
}
}

sb.Append(" }");

Thanks

Regards
Everton

2015-02-16 23:30 GMT+01:00, Atif Aziz <aziz...@gmail.com>:
> No, there is no annotation for that, I'm afraid. You could, however, take
> the sources of JsonRpcTester
> <https://code.google.com/p/jayrock/source/browse/src/Jayrock/JsonRpc/Web/JsonRpcTester.cs>
> and
> build on top to add the functionality you need. You could, for example, add
> an annotation that provides a template JSON for a parameter to supplied
> when testing.
>
> - Atif
>
> On Wed, Feb 11, 2015 at 8:46 AM, Everton Macedo <ever...@gmail.com>
> wrote:
>
>> Hi Atif.
>>
>> Is there a way to populate the model of the request parameters in the
>> help
>> page for frontend developers?
>> Current:
>>
>> <https://lh4.googleusercontent.com/-8ZMNsHcFQXs/VNsH_IJEg-I/AAAAAAAAExU/XCaFH2751zU/s1600/ema_ss37.png>
>>
>> It would be nice to have a expanded JsonObject beside of "null". Maybe
>> there is a annotation for that, which I don't know :)
>>
>> Regards.
>> Everton
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jayrock" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to jayrock+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jayrock" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jayrock/yFUSlmwVRjg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
--
*Everton Macedo
*

Atif Aziz

unread,
Feb 19, 2015, 3:00:37 PM2/19/15
to jay...@googlegroups.com
I quickly played with this idea & put together a demo. First I added a new attribute called JsonRpcTestExampleAttribute that can be decorated on methods like this:

[ JsonRpcMethod("add", Idempotent = true)]
[ JsonRpcHelp("Return the sum of two integers.") ]
[ JsonRpcTestExample("{ a: 123, b: 456 }") ]
public int Add(int a, int b)
{
    return a + b;
}

I then took the JsonRpcTester and turned it into an ASPX page with support for the attribute. I then added a JsonRpcHandler subclass that returns the ASPX when the test page is requested. If you drop the Jayrock.cs into App_Code of a Web Site project, together with JsonRpcTester.aspx and Demo.ashx in the root of the same Web Site and finally add Jayrock via NuGet then you should be able to take the whole demo for a ride.

Good luck,
Atif

Everton Macedo

unread,
Feb 20, 2015, 4:33:21 AM2/20/15
to jay...@googlegroups.com
Wow, 
Thank you for taking the time Atif.
I'll give it a try, and maybe serialise the model for the parameters automatically, so I don't have to update the JsonRpcTestExample attribute every time I add a property to the model. let's say

[ JsonRpcMethod("add", Idempotent = true)]
[ JsonRpcHelp("Return the sum of two integers.") ]
[ JsonRpcTestExample(typeof(Operands)) ]
public int Add(Operands op)
{
    return op.a + op.b;
}

Because I use complex parameters almost all the time.
I'll let you know if I get stuck :)
Regards 
Reply all
Reply to author
Forward
0 new messages