Infinity: Easier Than You Think. Infinitely.

Spaghettified musings on software

  • July 2019
    S M T W T F S
    « Jun    
  • Advertisements

Posts Tagged ‘rest’

Feeling Groovy: Quick Summary of a Jersey WADL

Posted by gdjsky01 on 2010/01/31

I have a Jersey based REST service and just needed a quick API summary. Groovy to the rescue! After grabbing the WADL (http://(whatever your context is)/application.wadl) I simply fed it to this little script. I am sure it could be improved to get the WADL itself, or read from stdin (which would be more Unix like) etc…

#!/usr/bin/env groovy
if (!this.args) {
System.err.println "usage summarize_wadl <wadl file> "
return -1

def s = [];
def nodes = new XmlParser().parseText(new File(this.args[0]).getText())
nodes.resources.resource.resource.each {
s << "${it.method.@id} => ${it.method.@name} => ${it.@path}"
s.sort().each { println it };
return 0

Got a better way? Faster way? More Groovy-o-matic (idiomatic) way? Teach us all! Leave a comment. I'll credit and incorporate ideas if allowed.


Posted in Coding, Groovy, scripting | Tagged: , , , , | Leave a Comment »