RESTful architecture file to openAPI file

Viewed 23

I'm new working with APIs and its documentation. However, I need to get an openAPI or swagger file from a RESTful API.

I have tried a couple of libraries (goswagger.io, rest.sh) and swaggerHub or Apimatic.io. However, I have not find a way to transform the file I have to a proper swagger structure.

Is it possible to get from the definition file I have for the RESTful API to an openAPI swagger?

Here is a snippet of the file I need to transform:

{
   "models":{
      "com.linkedin.analytics.GetTimeseriesAggregatedStatsResponse":{
         "namespace":"com.linkedin.analytics",
         "name":"GetTimeseriesAggregatedStatsResponse",
         "fields":[
            {
               "type":"string",
               "name":"entityName",
               "doc":"Input param entityName"
            },
            {
               "type":"string",
               "name":"aspectName",
               "doc":"Input param aspectName"
            },
            {
               "name":"filter",
               "doc":"Input param filter.",
               "optional":true,
               "type":{
                  "namespace":"com.linkedin.metadata.query.filter",
                  "name":"Filter",
                  "doc":"The filter for finding a record or a collection of records",
                  "fields":[
                     {
                        "name":"or",
                        "doc":"A list of disjunctive criterion for the filter. (or operation to combine filters)",
                        "optional":true,
                        "type":{
                           "type":"array",
                           "items":{
                              "name":"ConjunctiveCriterion",
                              "doc":"A list of criterion and'd together.",
                              "fields":[
                                 {
                                    "type":{
                                       "type":"array",
                                       "items":{
                                          "name":"Criterion",
                                          "doc":"A criterion for matching a field with given value",
                                          "fields":[
                                             {
                                                "type":"string",
                                                "name":"field",
                                                "doc":"The name of the field that the criterion refers to"
                                             },
                                             {
                                                "type":"string",
                                                "name":"value",
                                                "doc":"The value of the intended field"
                                             },
                                             {
                                                "name":"values",
                                                "doc":"Values. one of which the intended field should match\nNote, if values is set, the above \"value\" field will be ignored",
                                                "default":[
                                                   
                                                ],
                                                "type":{
                                                   "type":"array",
                                                   "items":"string"
                                                }
                                             },
                                             {
                                                "name":"condition",
                                                "doc":"The condition for the criterion, e.g. EQUAL, START_WITH",
                                                "default":"EQUAL",
                                                "type":{
                                                   "name":"Condition",
                                                   "doc":"The matching condition in a filter criterion",
                                                   "type":"enum",
                                                   "symbolDocs":{
                                                      "IS_NULL":"Represent the relation: field is null, e.g. platform is null",
                                                      "IN":"Represent the relation: String field is one of the array values to, e.g. name in [\"Profile\", \"Event\"]",
                                                      "EQUAL":"Represent the relation: field = value, e.g. platform = hdfs",
                                                      "CONTAIN":"Represent the relation: String field contains value, e.g. name contains Profile",
                                                      "GREATER_THAN":"Represent the relation greater than, e.g. ownerCount > 5",
                                                      "LESS_THAN_OR_EQUAL_TO":"Represent the relation less than or equal to, e.g. ownerCount <= 3",
                                                      "START_WITH":"Represent the relation: String field starts with value, e.g. name starts with PageView",
                                                      "LESS_THAN":"Represent the relation less than, e.g. ownerCount < 3",
                                                      "GREATER_THAN_OR_EQUAL_TO":"Represent the relation greater than or equal to, e.g. ownerCount >= 5",
                                                      "END_WITH":"Represent the relation: String field ends with value, e.g. name ends with Event"
                                                   },
                                                   "symbols":[
                                                      "CONTAIN",
                                                      "END_WITH",
                                                      "EQUAL",
                                                      "IS_NULL",
                                                      "GREATER_THAN",
                                                      "GREATER_THAN_OR_EQUAL_TO",
                                                      "IN",
                                                      "LESS_THAN",
                                                      "LESS_THAN_OR_EQUAL_TO",
                                                      "START_WITH"
                                                   ]
                                                }
                                             }
                                          ],
                                          "type":"record"
                                       }
                                    },
                                    "name":"and",
                                    "doc":"A list of and criteria the filter applies to the query"
                                 }
                              ],
                              "type":"record"
                           }
                        }
                     },
                     {
                        "name":"criteria",
                        "doc":"Deprecated! A list of conjunctive criterion for the filter. If \"or\" field is provided, then this field is ignored.",
                        "optional":true,
                        "type":{
                           "type":"array",
                           "items":"Criterion"
                        }
                     }
                  ],
                  "type":"record"
               }
            },
            {
               "name":"aggregationSpecs",
               "doc":"Input param aggregated metrics.",
               "optional":true,
               "type":{
                  "type":"array",
                  "items":{
                     "namespace":"com.linkedin.timeseries",
                     "name":"AggregationSpec",
                     "doc":"Provides the aggregation specification on a member/field.",
                     "fields":[
                        {
                           "type":"string",
                           "name":"fieldPath",
                           "doc":"Name of the member/field."
                        },
                        {
                           "type":{
                              "name":"AggregationType",
                              "type":"enum",
                              "symbols":[
                                 "LATEST",
                                 "SUM",
                                 "CARDINALITY"
                              ]
                           },
                           "name":"aggregationType",
                           "doc":"Aggregation type for the metric."
                        }
                     ],
                     "type":"record"
                  }
               }
            },
            {
               "type":{
                  "type":"array",
                  "items":{
                     "namespace":"com.linkedin.timeseries",
                     "name":"GroupingBucket",
                     "doc":"Defines the group by bucket definitions for time series requests.",
                     "fields":[
                        {
                           "type":{
                              "name":"GroupingBucketType",
                              "doc":"Defines a grouping bucket type.",
                              "type":"enum",
                              "symbols":[
                                 "DATE_GROUPING_BUCKET",
                                 "STRING_GROUPING_BUCKET"
                              ]
                           },
                           "name":"type",
                           "doc":"Type of the grouping bucket."
                        },
                        {
                           "type":"string",
                           "name":"key",
                           "doc":"Key that specifies the column name to be used as the timestamp field for bucketing."
                        },
                        {
                           "name":"timeWindowSize",
                           "doc":"Bucket size (like a day/hour etc) for the date grouping buckets.",
                           "optional":true,
                           "type":{
                              "name":"TimeWindowSize",
                              "doc":"Defines the size of a time window.",
                              "fields":[
                                 {
                                    "type":{
                                       "name":"CalendarInterval",
                                       "type":"enum",
                                       "symbols":[
                                          "SECOND",
                                          "MINUTE",
                                          "HOUR",
                                          "DAY",
                                          "WEEK",
                                          "MONTH",
                                          "QUARTER",
                                          "YEAR"
                                       ]
                                    },
                                    "name":"unit",
                                    "doc":"Interval unit such as minute/hour/day etc."
                                 },
                                 {
                                    "name":"multiple",
                                    "doc":"How many units. Defaults to 1.",
                                    "default":1,
                                    "type":"int"
                                 }
                              ],
                              "type":"record"
                           }
                        }
                     ],
                     "type":"record"
                  }
               },
               "name":"groupingBuckets",
               "doc":"Input param groupingBuckets"
            },
            {
               "type":{
                  "namespace":"com.linkedin.timeseries",
                  "name":"GenericTable",
                  "doc":"Defines a generic table.",
                  "fields":[
                     {
                        "type":{
                           "type":"array",
                           "items":"string"
                        },
                        "name":"columnNames",
                        "doc":"The names of the columns."
                     },
                     {
                        "type":{
                           "type":"array",
                           "items":"string"
                        },
                        "name":"columnTypes",
                        "doc":"The types of the columns."
                     },
                     {
                        "name":"rows",
                        "doc":"The data rows.",
                        "optional":true,
                        "type":{
                           "type":"array",
                           "items":{
                              "type":"array",
                              "items":"string"
                           }
                        }
                     }
                  ],
                  "type":"record"
               },
               "name":"table",
               "doc":"The results table."
            },
            {
               "name":"lastUpdatedTimeMillis",
               "doc":"When the index was last updated.",
               "optional":true,
               "type":"long"
            }
         ],
         "type":"record"
      },
    ...
},
   "resources":{
      "com.linkedin.entity.entities":{
         "schema":"com.linkedin.entity.Entity",
         "namespace":"com.linkedin.entity",
         "name":"entities",
         "doc":"Single unified resource for fetching, updating, searching, & browsing DataHub entities\n\ngenerated from: com.linkedin.metadata.resources.entity.EntityResource",
         "path":"/entities",
         "collection":{
            "supports":[
               "batch_get",
               "get"
            ],
            "identifier":{
               "type":"string",
               "name":"entitiesId"
            },
            "actions":[
               {
                  "name":"autocomplete",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"entity"
                     },
                     {
                        "type":"string",
                        "name":"query"
                     },
                     {
                        "type":"string",
                        "name":"field",
                        "optional":true
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.Filter",
                        "name":"filter",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"limit"
                     }
                  ],
                  "returns":"com.linkedin.metadata.query.AutoCompleteResult"
               },
               {
                  "name":"batchGetTotalEntityCount",
                  "parameters":[
                     {
                        "type":"{ \"type\" : \"array\", \"items\" : \"string\" }",
                        "name":"entities"
                     }
                  ],
                  "returns":"{ \"type\" : \"map\", \"values\" : \"long\" }"
               },
               {
                  "name":"batchIngest",
                  "parameters":[
                     {
                        "type":"{ \"type\" : \"array\", \"items\" : \"com.linkedin.entity.Entity\" }",
                        "name":"entities"
                     },
                     {
                        "type":"{ \"type\" : \"array\", \"items\" : \"com.linkedin.mxe.SystemMetadata\" }",
                        "name":"systemMetadata",
                        "optional":true
                     }
                  ]
               },
               {
                  "name":"browse",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"entity"
                     },
                     {
                        "type":"string",
                        "name":"path"
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.Filter",
                        "name":"filter",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"start"
                     },
                     {
                        "type":"int",
                        "name":"limit"
                     }
                  ],
                  "returns":"com.linkedin.metadata.browse.BrowseResult"
               },
               {
                  "name":"delete",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"urn"
                     }
                  ],
                  "returns":"com.linkedin.metadata.run.DeleteEntityResponse"
               },
               {
                  "name":"deleteAll",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"registryId",
                        "optional":true
                     },
                     {
                        "type":"boolean",
                        "name":"dryRun",
                        "optional":true
                     }
                  ],
                  "returns":"com.linkedin.metadata.run.RollbackResponse"
               },
               {
                  "name":"deleteReferences",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"urn"
                     },
                     {
                        "type":"boolean",
                        "name":"dryRun",
                        "optional":true
                     }
                  ],
                  "returns":"com.linkedin.metadata.run.DeleteReferencesResponse"
               },
               {
                  "name":"exists",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"urn"
                     }
                  ],
                  "returns":"boolean"
               },
               {
                  "name":"filter",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"entity"
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.Filter",
                        "name":"filter"
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.SortCriterion",
                        "name":"sort",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"start"
                     },
                     {
                        "type":"int",
                        "name":"count"
                     }
                  ],
                  "returns":"com.linkedin.metadata.search.SearchResult"
               },
               {
                  "name":"getBrowsePaths",
                  "parameters":[
                     {
                        "type":"com.linkedin.common.Urn",
                        "name":"urn"
                     }
                  ],
                  "returns":"{ \"type\" : \"array\", \"items\" : \"string\" }"
               },
               {
                  "name":"getTotalEntityCount",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"entity"
                     }
                  ],
                  "returns":"long"
               },
               {
                  "name":"ingest",
                  "parameters":[
                     {
                        "type":"com.linkedin.entity.Entity",
                        "name":"entity"
                     },
                     {
                        "type":"com.linkedin.mxe.SystemMetadata",
                        "name":"systemMetadata",
                        "optional":true
                     }
                  ]
               },
               {
                  "name":"list",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"entity"
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.Filter",
                        "name":"filter",
                        "optional":true
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.SortCriterion",
                        "name":"sort",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"start"
                     },
                     {
                        "type":"int",
                        "name":"count"
                     }
                  ],
                  "returns":"com.linkedin.metadata.query.ListResult"
               },
               {
                  "name":"listUrns",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"entity"
                     },
                     {
                        "type":"int",
                        "name":"start"
                     },
                     {
                        "type":"int",
                        "name":"count"
                     }
                  ],
                  "returns":"com.linkedin.metadata.query.ListUrnsResult"
               },
               {
                  "name":"search",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"entity"
                     },
                     {
                        "type":"string",
                        "name":"input"
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.Filter",
                        "name":"filter",
                        "optional":true
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.SortCriterion",
                        "name":"sort",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"start"
                     },
                     {
                        "type":"int",
                        "name":"count"
                     }
                  ],
                  "returns":"com.linkedin.metadata.search.SearchResult"
               },
               {
                  "name":"searchAcrossEntities",
                  "parameters":[
                     {
                        "type":"{ \"type\" : \"array\", \"items\" : \"string\" }",
                        "name":"entities",
                        "optional":true
                     },
                     {
                        "type":"string",
                        "name":"input"
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.Filter",
                        "name":"filter",
                        "optional":true
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.SortCriterion",
                        "name":"sort",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"start"
                     },
                     {
                        "type":"int",
                        "name":"count"
                     }
                  ],
                  "returns":"com.linkedin.metadata.search.SearchResult"
               },
               {
                  "name":"searchAcrossLineage",
                  "parameters":[
                     {
                        "type":"string",
                        "name":"urn"
                     },
                     {
                        "type":"string",
                        "name":"direction"
                     },
                     {
                        "type":"{ \"type\" : \"array\", \"items\" : \"string\" }",
                        "name":"entities",
                        "optional":true
                     },
                     {
                        "type":"string",
                        "name":"input",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"maxHops",
                        "optional":true
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.Filter",
                        "name":"filter",
                        "optional":true
                     },
                     {
                        "type":"com.linkedin.metadata.query.filter.SortCriterion",
                        "name":"sort",
                        "optional":true
                     },
                     {
                        "type":"int",
                        "name":"start"
                     },
                     {
                        "type":"int",
                        "name":"count"
                     }
                  ],
                  "returns":"com.linkedin.metadata.search.LineageSearchResult"
               },
               {
                  "name":"setWritable",
                  "parameters":[
                     {
                        "type":"boolean",
                        "name":"value",
                        "default":"true"
                     }
                  ]
               }
            ],
            "entity":{
               "path":"/entities/{entitiesId}"
            },
            "methods":[
               {
                  "method":"get",
                  "parameters":[
                     {
                        "type":"{ \"type\" : \"array\", \"items\" : \"string\" }",
                        "name":"aspects",
                        "optional":true
                     }
                  ],
                  "doc":"Retrieves the value for an entity that is made up of latest versions of specified aspects."
               },
               {
                  "method":"batch_get",
                  "parameters":[
                     {
                        "type":"{ \"type\" : \"array\", \"items\" : \"string\" }",
                        "name":"aspects",
                        "optional":true
                     }
                  ]
               }
            ]
         }
      },
...

Thank you in advance!

0 Answers
Related