How to generate API-Proxy meta data in JSON/WADL format?

Use Case

We have few API proxies hosted in Private Cloud and require to generate proxy description of these existing apis in JSON/WADL ( or any other structure if these are not supported). Idea is to build simple documentation of existing APIs (Base url, Source names, supported HTTP VERB, Input and Output parameters).

2 3 10.3K
3 REPLIES 3

This can be done manually only, there is no way to generate proxy description through some other process.

For manually creating proxy description of apis with the help of swagger:

https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md

There are tools for exporting the API PRoxy definition into various formats.

Certainly, JSON is easy to generate. For example, this command gets the definition of an API Proxy in JSON format:

curl -i -n https://api.enterprise.apigee.com/v1/o/ORGNAME/apis/APIPROXYNAME/revisions/2/proxies/default

the response looks like this:

{
  "connection" : {
    "basePath" : "/kvm2",
    "connectionType" : "httpConnection",
    "virtualHost" : [ "default" ]
  },
  "connectionType" : "httpConnection",
  "description" : "Default Proxy",
  "faultRules" : [ ],
  "flows" : [ {
    "condition" : "(proxy.pathsuffix MatchesPath \"/add\") and (request.verb = \"GET\")",
    "description" : "PUT one entry into a map",
    "name" : "put one token",
    "request" : {
      "children" : [ {
        "Step" : {
          "faultRules" : [ ],
          "name" : "KVM-PutToken"
        }
      }, {
        "Step" : {
          "faultRules" : [ ],
          "name" : "KVM-GetList"
        }
      } ]
    },
    "response" : {
      "children" : [ {
        "Step" : {
          "faultRules" : [ ],
          "name" : "AssignMessage-PutToken"
        }
      } ]
    }
  }, {
    "condition" : "(proxy.pathsuffix MatchesPath \"/list\") and (request.verb = \"GET\")",
    "name" : "get the KVM entry",
    "request" : {
      "children" : [ {
        "Step" : {
          "faultRules" : [ ],
          "name" : "KVM-GetList"
        }
      } ]
    },
    "response" : {
      "children" : [ {
        "Step" : {
          "faultRules" : [ ],
          "name" : "AssignMessage-GetList"
        }
      } ]
    }
  }, {
    "name" : "unknown request",
    "request" : {
      "children" : [ {
        "Step" : {
          "faultRules" : [ ],
          "name" : "RaiseFault-UnknownRequest"
        }
      } ]
    },
    "response" : {
      "children" : [ ]
    }
  } ],
  "name" : "default",
  "postFlow" : {
    "name" : "PostFlow",
    "request" : {
      "children" : [ ]
    },
    "response" : {
      "children" : [ {
        "Step" : {
          "faultRules" : [ ],
          "name" : "AssignMessage-CleanResponseHeaders"
        }
      } ]
    }
  },
  "preFlow" : {
    "name" : "PreFlow",
    "request" : {
      "children" : [ ]
    },
    "response" : {
      "children" : [ ]
    }
  },
  "routeRule" : [ {
    "empty" : true,
    "name" : "NoTargetRouteRule"
  } ],
  "routeRuleNames" : [ "NoTargetRouteRule" ],
  "type" : "Proxy"
}
 

As you can see, it's JSON, and it includes the basepath, the methods and resources, and so on. This could be mechanically transformed into other formats and layouts, of course.

HTH

If you are looking to generate documentation and leverage apigee smartdocs, you could use this utility,

https://github.com/mukundha/apigee-api-model-generator

The documentation can be published in portal or consumed directly using the management server APIs