Working With Anonymous Objects

An object type in an OpenAPI swagger document is exposed as an object variable in the FLOW graphical user interface. An anonymous object is an object that is marked explicitly as type ‘object’ in such a document. Since the FLOW user interface cannot display anonymous objects in the drop-down lists for defining variables, you cannot import a document containing one or more such objects for use in your scripts. (Documents are imported into FLOW via storm STUDIO as described in the storm STUDIO User Guide.)

For example, a document containing the following definition cannot be imported into FLOW because the array 'WeatherForecast' contains an anonymous object (defined as 'object').

{"type": "array","items": 
  {"type": "object","properties":
    {"date":
      {"type": "string", "format": "date-time"
      },"temperatureC":
        {"type": "integer", "format": "int32"
        }
    }
  }    
}

If your swagger document uses OpenAPI v3.0.0 or above, you can work around this limitation by importing a modified version of your original swagger document.

The original document is shown below. The yellow-highlighted content in this document can be replaced by the highlighted content shown in the modified document further below.

{
"openapi": "3.0.1","info": 
  {"title": "WeatherForecast","version": "v1"
  },"paths": 
    {"/WeatherForecast": 
      {"get": 
        {"tags": ["WeatherForecast"],"responses":
          {"200": 
            {"description": "Success","content":
              {"application/json":
                {"schema": 
                 {"type": "array","items": 
                    {"type": "object","properties":
jjjjjjjjjjjjjjjjjjjjjjjj{"date":
jjjjjjjjjjjjjjjjjjjjjjjjjj{"type": "string", "format": "date-time"
jjjjjjjjjjjjjjjjjjjjjjjjjj},"temperatureC":
jjjjjjjjjjjjjjjjjjjjjjjjjjjj{"type": "integer", "format": "int32"
jjjjjjjjjjjjjjjjjjjjjjjjjjjj}
jjjjjjjjjjjjjjjjjjjjjjjj}
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
}

The modified document is show below. Here, the anonymous object as shown in the original document above has been removed from the array. The array now references the named schema component ‘WeatherForecast’, which is of type ‘object’.

{
"openapi": "3.0.1","info": 
  {"title": "WeatherForecast","version": "v1"},"paths": 
    {"/WeatherForecast": 
      {"get": 
        {"tags": ["WeatherForecast"],"responses":
          {"200": 
            {"description": "Success","content":
              {"application/json":
                {"schema": 
                  {"type": "array","items": 
                    {"$ref": "#/components/schemas/WeatherForecast"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    
jj"components": 
jj{"schemas":
jjjj{"WeatherForecast": 
jjjjjj{"type": "object","properties":
jjjjjjjj{"date":
jjjjjjjjjj{"type": "string","format": "date-time"
jjjjjjjjjj},"temperatureC":
jjjjjjjjjjjj{"type": "integer","format": "int32"
jjjjjjjjjjjj}
jjjjjjjj}
jjjjjj}
jjjj}
jj}
}

By using this modified swagger document, you can then store the result of the ‘WeatherForecast’ response in a variable of type array (for example, arrobjWeatherForecast) supporting the 'WeatherForecast' objects:

You can then use the array variable as an output in the REST API action cell: