DiTieM,

The key

   "parameters": {
    "$ref": "UserApiMessagesUserGetProfileStatsQ"
   },

is *not* the expected behavior.

This is a special backend configuration for the API and certain properties 
(such as required or path parameters) show up as parameters while the rest 
go in "body" as a $ref to a schema. For GET and DELETE requests, there is 
no body at all (per the HTTP spec), so all attributes are parameters.

On Monday, April 22, 2013 3:48:01 AM UTC-7, DiTieM wrote:
>
> Simple command:
>
> endpointscfg.py  gen_discovery_doc -o ~/projects/TestApp/generated -f rpc 
> services.UserApi
>
> Generates wrong discovery file. The piece of code that is failing is this 
> (I removed all that was not relevant)
>
> @endpoints.api( name='user', version='v1', description='User API'
>               , allowed_client_ids=PERMS
>               , hostname=g_hostname )
> class UserApi(remote.Service):
>
>     @endpoints.method(UserGetProfileStatsQ, UserGetProfileStatsA
>                       , path='user/stats'
>                       , name='user.get_stats'
>                       , http_method='GET'
>                       )
>     def get_profile_stats(self, request):
>         ...
>         return UserGetProfileStatsA( ... )
>
>
>     @endpoints.method(UserSetProfileQ, message_types.VoidMessage
>                       , path='user/profile'
>                       , name='user.save_profile'
>                       , http_method='POST'
>                       )
>     def set_profile(self, request):
>         ...
>         return message_types.VoidMessage( )
>             
>
>     @endpoints.method(message_types.VoidMessage, UserGetProfileA
>                       , path='user/profile'
>                       , name='user.get_profile'
>                       , http_method='GET'
>                       )
>     def get_profile(self, request):
>         ...
>         return UserGetProfileA( ... )
>
>
>
> The first method, get_profile_stats, in the discovery file, instead of 
>
>   "user.user.getstats": {
>    "id": "user.user.getstats",
>    "allowGet": true,
>    "parameters": {
>     "$ref": "UserApiMessagesUserGetProfileStatsQ"
>    },
>    "returns": {
>     "$ref": "UserApiMessagesUserGetProfileStatsA"
>    },
>
> generates something like:
>
>   "user.user.getstats": {
>    "id": "user.user.getstats",
>    "allowGet": true,
>    "parameters": {
>     "dummy": {
>      "type": "string"
>     },
>     "user_id": {
>      "type": "string"
>     }
>    },
>    "returns": {
>     "$ref": "UserApiMessagesUserGetProfileStatsA"
>    },
>
> Basically, it has "expanded" the UserApiMessagesUserGetProfileStatsQ to 
> its fields. Therefore, the next step generates libraries for iOS that do 
> not require any argument when doing the query for "get_user_profile_stats".
>
> Some things I have found:
>
> - If the name in endpoints.method match in 2 different functions but 
> differ in http_method, the generation fails too. Example, I want to user 
> user/profile (name="user.profile" for both: get_profile and set_profile) 
> with GET HTTP method to read it, and with POST HTTP method to modify it. It 
> cannot be done.
>
> - If the method of get_user_stats has HTTP method = "PUT" (whatever that 
> is not POST or GET), it generates "correctly" the discovery file.
>
> I am wondering if I am misunderstanding the meaning of "path" and "name" 
> fields in the endpoints.method. Or maybe I misunderstood the whole 
> endpoints thing, and it is 1 class per each set of "PUT", "GET", "POST", 
> ... methods (but in the tictactoe example there are 2 POST and 1 GET in the 
> same class).
>
> Any help is highly appreciated. Thanks in advance!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to