Git Product home page Git Product logo

wadl2go's Introduction

wadl2go

wadl2go parses a .wadl file and emits a go client.

Usage:

Usage of wadl2go:
  -base-url="": Specifies a replacement for the given base URL.
  -debug=false: Controls debug log messages
  -package-name="main": Specifies the package the generated file will be under.
  -to-file="": Specifies the destination file
  -wadl-file="": Specifies which file to parse

Requirements

Rendering the output execs the gojson tool to generate go structs for json data. This must be installed, and $GOPATH/bin must be on your path:

go get github.com/ChimeraCoder/gojson/gojson

The go xml parser does not understand DTDs. If the input file uses these, the wadl input will need preprocessing to resolve external entities and replace them. For example:

xmllint --loaddtd --noent --dropdtd example.wadl > example-noent.wadl

Disclaimer

Currently, this is just a wonderfully hacky thing I coded up in a few days to generate a client for Openstack’s Cinder. Because of ambiguities in the WADL format, it can be difficult to reliably generate code without relying on some inference. This inference is very nascent at the moment.

Much work could be done to improve this tool; however, I thought this might help someone out if it wasn’t sitting on my computer bit-rotting.

Caveats

  • wadl2go only considers JSON requests and response types.
  • If you include files in the grammar sections, wadl2go makes some assumptions about the content of these files.
    • Currently only .json files are supported, and wadl2go assumes these are JSON Schema files.
    • How these files are referenced is unfortunately not covered by the WADL specification. wadl2go currently looks for the “json:ref” attribute and will cross-reference the URI specified with URI’s specified in the grammar file.
  • wadl2go only consumes 1 doc element per representation.
  • Documentation is currently poorly scrubbed for XML elements in an attempt to derive plain ASCII documentation. UTF documentation was not considered.
  • The autogenerated code is not formatted, nor are requisite imports added. It assumes you will format the standard Go tooling to take care of this.
  • The responses are currently derived from JSON examples. This produces unwieldy anonymous structures. This will be fixed in the very near future.

Suggested Improvements

General

These are useful feedback as to whether or not the response is reasonable. wadl2go should inspect the return type to determine if JSON deserialization is warranted.

Clean up this mess of a codebase.

Support XML representations.

Support > 1 documentation blocks for each representation.

Support automatic gofmt.

Inference

Look at all attributes on response/request representations and attempt to find URI’s that match grammar elements.

Examine included grammar files to better determine what format we’re looking at.

wadl2go's People

Contributors

kat-co avatar bz2 avatar

Stargazers

otokunaga avatar Saeed Rasooli avatar SPARON avatar Joe Topjian avatar Michael Lore avatar Jay R. Wren avatar Shuduo Sang avatar Matt Bruzek avatar ACoder avatar

Watchers

James Cloos avatar Matt Bruzek avatar  avatar

Forkers

bz2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.