Passing dictionary object as part of request to ServiceStack Swagger

I am currently working with the ServiceStack Swagger plugin and am having trouble filling in certain objects in my query, especially in vocabulary subjects.

In the following image, I want to pass a dictionary <string, string> object as JSON to FieldFilter. What is the format for this? I tried some examples, but the FieldFilter object is always deserialized as null.

enter image description here UPDATE

I went through the JSON example given in this link:

http://www.newtonsoft.com/json/help/html/SerializeDictionary.htm

which shows the Dictionary <string, string> JSON representation looks like this:

{
   "James": "9001",
   "Jo": "3474",
   "Jess": "11926"
}

      

but the result is still deserialized to zero. I think this is more of a limitation of ServiceStack and the Swagger plugin. I'll take on the suggestion to use a list of classes and provide another update

UPDATE 2

I tried to create a FieldFilter class (which contains two string properties). This is the JSON I am currently entering:

{
  "FieldId": "1",
  "Value": "Hello"
},
{
  "FieldId": "2",
  "Value": "Goodbye"
}

      

Attempting this (and other small changes) the field is still deserialized as null.

As a test, I added a field filter object to my CreateUser request, which has a single body with all the required fields. The JSON for this looks like this:

{
  "FieldFilter": [
    {
      "FieldId": "1",
      "Value": "Hello"
    },
    {
      "FieldId": "2",
      "Value": "Goodbye"
    }
  ],
  "FirstName": "",
  "LastName": "",
  "Password": "",
  "Permissions": [
    ""
  ],
  "Roles": [
    ""
  ],
  "Username": ""
}

      

Now in this example, where all the fields are in one JSON request, the FieldFilter is deserialized with the correct values! Is there any reason why it works here? Am I missing something painfully obvious?

+3
dictionary servicestack swagger swagger-ui


source to share


No one has answered this question yet

Check out similar questions:

4
Using ServiceStack Swagger Plugin how to implement a combo box string
3
Deserialize JSON descriptor in ServiceStack in multipart / form-data request
3
How to get a Swagger plugin working in a self-serve service
3
ServiceStack does not deserialize dictionary <string, object> as expected
2
Using ServiceStack JsonSerializer to Serialize Arrays Containing Some Null Elements
2
How to define Swagger 2.0 JSON to populate the default object body object in Swagger UI?
2
Removing Deserialization of Nested JSON Objects with ServiceStack
1
Deserialize Boolean from Soap with Servicestack
1
Create sample request in Swagger codegen
0
ServiceStack Swagger Additional fields in DTO request



All Articles
Loading...
X
Show
Funny
Dev
Pics