Infinity: Easier Than You Think. Infinitely.

Spaghettified musings on software

  • January 2010
    S M T W T F S
    « Oct   May »
  • Advertisements

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: