Contracts icon indicating copy to clipboard operation
Contracts copied to clipboard

How to describe an array of specified objects?

Open muturgan opened this issue 3 years ago • 1 comments

I have tried to validate a return-value at the "api.example.countries" method from the example reposytory. It returns something like this:

{
  result: "success",
  data: [{
    countryId: "1",
    name: "Soviet Union"
  }]
}

I have modified this method:

({
  access: 'public',

  returns: {
    result: 'string',
    data: {
      type: 'array',
      value: {
        countryId: 'string',
        name: 'string',
      },
    },
  },

  method: .....
});

And now I see an error in the browser console on a method call: Invalid result type: Field "data" expected to be array of [object Object]. Of cause I can define the data as

data: {
  type: 'array',
  value: 'object'
}

But it is not strict.

So how I can define a schema in a right way?

muturgan avatar Sep 10 '21 13:09 muturgan

There is no such feature now, so I will give an implementation very soon.

georgolden avatar Jan 11 '22 06:01 georgolden