Forum Discussion

BostonKevin's avatar
BostonKevin
Contributor
6 years ago
Solved

Way to Model Response An Array of Different Objects With Identical Properties

Hi!

 

In Swagger Editor is there a way to model an array of objects each of which has identical properties but with different values for these properties?  This array is in a response to a delete operation and has the following structure:

{
  "Modifications_Following_DELETE": [
    {
      "rows_deleted": 0,
      "table_name": "Table_X"
    },
    {
      "rows_deleted": 0,
      "table_name": "Table_XX"
    },
    {
      "rows_deleted": 0,
      "table_name": "Table_BBBB"
    },
    {
      "rows_deleted": 0,
      "table_name": "Table_CCC"
    },
    {
      "rows_deleted": 1,
      "table_name": "Table_DDD"
    },
    {
      "rows_deleted": 0,
      "table_name": "Table_EEE"
    },
    {
      "rows_deleted": 0,
      "table_name": "Table_FFF"
    },
    {
      "rows_deleted": 0,
      "table_name": "Table_HHH"
    },
    {
      "rows_deleted": 0,
      "table_name": "Table_III"
    }
  ]
}

It is easy enough to model an array  consisting of objects, but getting the names of all the tables is not obvious. Perhaps there is a way?  

 

Thanks!

17 Replies

  • Looks like it's just an array of the same object. The value of specific fields isn't really relevant. Do you have an initial definition to share?

    • BostonKevin's avatar
      BostonKevin
      Contributor

      Each one of those objects is unique, even if it does not look so.  In order to describe all the data that is returned i.e. information on the number of rows deleted from different tables, in the Swagger Editor, each of the objects would have to have a unique ID of some kind.  In the example i provided, the 'ID' is the value of the table_name field. As a result,  I cannot model the full response.

       

      If each one of those objects were defined as a distinct kind of object in an array, I could model the complete response i.e. precise information on the rows deleted in different tables.  Do you see what I mean?

       

      I think that this is more of a coding issue  than a Swagger issue, and will suggest a coding change to the development team. 

      • Unfortunately, I don't understand the problem. In the example you provided, each array entry is an object with two properties.rows_deleted and table_name. The fact that they have different values in the actual response doesn't change anything with regard to the modeling. rows_deleted would be of type integer, table_name would be a string, and that's pretty much it. What am I missing?