Hi
I am using Scalatra for my API server, with docs generated by swagger-ui. I am then taking this spec from the API server and generating client code in Python and PHP.
My model looks something like this:
User
{"userId":X,"userData":{"field1":"val1","field2":"val2",...}}
It's a very simple representation. I want to have arbitrary data stored in a Map[String, String] in Scala.
Now, when I post a User using the Python code, all is well:
> user = User()
> user.userId = 1
> user.userData = {"field":"value"}
> uapi.postUser(user)
However, when I retrieve a user, I get:
In [15]: user = uapi.getUserById(1)
In [16]: user.userId
Out[16]: 1L
In [17]: user.userData
Out[17]: <models.User.User instance at 0x1052f5878>
In [18]: user.userData.userData
In [19]:
So the Map[String, String] became a User instance, and the userData of that is blank.
Same seems to apply to PHP - I don't use PHP but a customer is telling me that the PHP client cannot deserialize the Map[String, String] piece
Any thoughts on how to fix this? It seems from the Python codegen that it cannot map "Map" to "dict" in Python. Not sure if there is a way around it other than to amend the generated code?
Anyone else come across this?
Thanks
Nick
====
User.py looks like:
class User:
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually."""
def __init__(self):
self.swaggerTypes = {
'userData': 'Map[string,string]',
'userId': 'long',
'otherIds': 'list[String]'
}
#
self.userData = None # Map[string,string]
#
self.userId = None # long
#
self.otherIds = None # list[String]
====