Active IQ Unified Manager Discussions

Swagger file export from WFA

GregGuignard
4,240 Views

1. I want to publish WFA workflows through an API broker that accepts swagger files as input to define the API. This works for NSLM by grabbing https://{nslm_server_hostname}:{port}/swagger.json file, but when I attempt to grab the /swagger.json file from the WFA server, which is located at https://{wfa_server_hostname}/rest/swagger.json, it's not in valid JSON format, it's just 1 long line of code. Has anyone had any success with the WFA swagger file?

 

2. Is there anyway to export individual workflows from WFA as swagger formatted files thatt can be used to import into other tools? 

4 REPLIES 4

MartinRohrbach
4,023 Views

Just tested this with both WFA 4.1 and 4.2. I can download the file and it's valid JSON in both cases (as determined by the Perl JSON package).

 

You're saying you get a long line of code, can you maybe post an example of what you're seeing?

 

 

GregGuignard
3,995 Views

When viewing the /rest/swagger.json file from the WFA server in the browser it's one long continuously wrapping line of code. When copied and pasted into a JSON file in VS Code it's a single continuous non-wrapping line. I only posted a little bit because it's so long.

 

{"swagger":"2.0","info":{"version":"1.0","title":""},"basePath":"/rest","tags":[{"name":"Execution:Workflows"},{"name":"Execution:Data Sources"},{"name":"System:Backups"},{"name":"Designer:Remote System Types"},{"name":"System:System"},{"name":"System:User Management"},{"name":"Designer:Packs"},{"name":"Designer:Filters and Finders"},{"name":"Execution:Credentials"},{"name":"System:AutoSupport"},{"name":"System:Search"},{"name":"Execution:Schedules"},{"name":"Designer:Export and Import"},{"name":"Designer:Data Source Types"}],"paths":{"/backups":{"get":{"tags":["System:Backups"],"summary":"Backup the resources to local file","description":"Response with URL of backup file to be downloaded.<br><br><font color=\"red\"> Note: This documentation tool does not support testing this API.</font>","operationId":"backupAndLinkToLocalFile","parameters":[{"name":"full","in":"query","description":"Whether to perform a full backup. Full backup includes application configuration data along with normal backup content.<br> NOTE: Full backup contains the credentials of the storage systems added into WFA. Restoring this backup will provide access to all the storage systems.","required":false,"type":"string"}],"responses":{"default":{"description":"successful operation"}}},"post":{"tags":["System:Backups"],"summary":"Restores the resources from external backup file","description":"Input must be in multipart/form-data format. The KeyName for backup file in the form data must be \"backupFile\".<br>On success, response will have no content, in case of failure response has the error message.<br><br><font color=\"red\"> Note: This documentation tool does not support testing this API.</font>","operationId":"restoreFromExternalBackupPost","consumes":["multipart/form-data"],"parameters":[{"in":"body","name":"body","description":"The backup file with KeyName as \"backupFile\"","required":false,"schema":

 

If I could get this properly formatted, I'd only want to have the swagger file definitions for specific workflows, not the entire catalog. Is there any way to 'export' a workflow interface as a swagger file definition?

MartinRohrbach
3,900 Views

Not sure what you are saying. This is not "a line of code" but valid JSON that describes the actual WFA REST API.

 

You can then actually use that WFA REST API to query WFA for the workflows. If that's what you want you might be better off looking at the REST API documentation at /rest/docs or reading the WFA REST API primer. There is a /workflow GET call which will return all workflows and even a /workflow/<uuid> GET call which will return info on a specific workflow in either JSON or XML.

GregGuignard
3,890 Views

I know it looks like valid JSON, but it doesn't behave like it when viewed in VisualStudio Code or Notepad ++. These will both recognize valid JSON formatting, it's a single line of 100,000+ characters.

 

For example.

 

When I use a browser to view https://{NSLM-server}:8443/swagger.json, this is what the first few lines of the page looks like ...

 

{
  "basePath": "/api",
  "schemes": [
    "https"
  ],
  "swagger": "2.0",
  "tags": [
    {
      "name": "events",
      "description": "Event operations [Role: Administrator, Operator]"
    },
    {
      "name": "admin",
      "description": "Admin operations [Role: Administrator]"
    },
    {
      "name": "jobs",
      "description": "Job operations [Roles: Administrator, Operator]"
    },
    {
      "name": "ontap2.0",
      "description": "Clustered Data ONTAP operations [Roles: Administrator, Monitor, Operator]"
    },
    {
      "name": "slo",
      "description": "SLO operations [Roles: Administrator, Operator]"
    }
  ],

 In contrast, when I use a browser to view the swagger.json for WFA (https://{WFA-Server}/rest/swagger.json) is this what the first few lines of the page look like ... all 101,400 characters on a single line.

 

{"swagger":"2.0","info":{"version":"1.0","title":""},"basePath":"/rest","tags":[{"name":"Execution:Workflows"},{"name":"Execution:Data Sources"},{"name":"System:Backups"},{"name":"Designer:Remote System Types"},{"name":"System:System"},{"name":"System:User Management"},{"name":"Designer:Packs"},{"name":"Designer:Filters and Finders"},{"name":"Execution:Credentials"},{"name":"System:AutoSupport"},{"name":"System:Search"},{"name":"Execution:Schedules"},{"name":"Designer:Export and Import"},{"name":"Designer:Data Source Types"}],"paths":{"/backups":{"get":{"tags":["System:Backups"],"summary":"Backup the resources to local file","description":"Response with URL of backup file to be downloaded.<br><br><font color=\"red\"> Note: This documentation tool does not support testing this API.</font>","operationId":"backupAndLinkToLocalFile","parameters":[{"name":"full","in":"query","description":"Whether to perform a full backup. Full backup includes application configuration data along with normal backup content.<br> NOTE: Full backup contains the credentials of the storage systems added into WFA. Restoring this backup will provide access to all the storage systems.","required":false,"type":"string"}],"responses":{"default":{"description":"successful operation"}}},"post":{"tags":["System:Backups"],"summary":"Restores the resources from external backup file","description":"Input must be in multipart/form-data format. The KeyName for backup file in the form data must be \"backupFile\".<br>On success, response will have no content, in case of failure response has the error message.<br><br><font color=\"red\"> Note: This documentation tool does not support testing this API.</font>","operationId":"restoreFromExternalBackupPost","consumes":["multipart/form-data"],"parameters":[{"in":"body","name":"body","description":"The backup file with KeyName as \"backupFile\"","required":false,"schema":{"$ref":"#/definitions/MultipartFormDataInput"}},{"name":"full","in":"query","description":"Whether to perform a full restore, If this parameter is true while specifying a normal backup file, normal backup will be performed, similarly if this parameter is false and a full backup file is specified, a normal backup will be performed.","required":false,"type":"string"}],"responses":{"default":{"description":"successful operation"}}},"put":{"tags":["System:Backups"],"summary":"Restores the resources from external backup file","description":"Input must be in multipart/form-data format. The KeyName for backup file in the form data must be \"backupFile\".<br>On success, response will have no content, in case of failure response has the error message.<br><br><font color=\"red\"> Note: This documentation tool does not support testing this API.</font>","operationId":"restoreFromExternalBackup","consumes":["multipart/form-data"],"parameters":[{"in":"body","name":"body","description":"The backup file with KeyName as \"backupFile\"","required":false,"schema":{"$ref":"#/definitions/MultipartFormDataInput"}},{"name":"full","in":"query","description":"Whether to perform a full restore, If this parameter is true while specifying a normal backup file, normal backup will be performed, similarly if this parameter is false and a full backup file is specified, a normal backup will be performed","required":false,"type":"string"}],"responses":{"default":{"description":"successful operation"}}}},"/credentials":{"get":{"tags":["Execution:Credentials"],"summary":"Retrieves the list of configured credentials in the system","description":"","operationId":"getCredentials","consumes":["application/xml","application/json"],"produces":["application/xml","application/json"],"parameters":[{"name":"type","in":"query","description":"ConnectionType. Valid values are ONT

 

Thanks for the suggestion on the /rest/docs swagger interface. We're already using that to query, call, and validate workflows. The real goal of all this is to export the JSON that describes the actual WFA REST API so that it can be imported into another API abstraction tool called API Connect by IBM.  Even if I could get the entire WFA swagger.json file properly formatted, I wouldn't want to import the entire thing into the customer facing asbtraction layer. I only want to publish a few of the WFA REST API functions. For example /workflows is something useful for my customers, but I don't need to export the /datasources, /backups, /dars, or /packs collections. 

 

Thanks for any suggestions you can offer.

 

Public