-
Notifications
You must be signed in to change notification settings - Fork 19
Home
The API Checker library allows checking a rest servlet against a contract written in WADL. The library is meant to be used within a servlet filter a sample servlet filter is in the filter directory.
The API Checker library has the following phases to create a validator given a WADL:
Phase 1: Normalize WADL
Phase 2: WADL to Checker format (custom XML format)
Phase 3: Optimizations on checker format
Phase 4: Checker format to state machine
A WADL may have external resources (XSDs, other WADL references) that are needed in order to produce a complete state machine to support the validation of a request. The normalize phase does the following:
- Resolve external resources
- Converts from flat format to tree format
- Resolve resource types
- Validates WADL and throws appropriate error if the WADL is in a bad format
- Generates a single wadl file that can then be used by Phase 2.
Development Tips
To manually normalize a WADL to support testing of phase 2:
- Clone the wadl-tools repository $ git clone [email protected]:rackerlabs/wadl-tools.git
- Normalize your WADL using the wadltools utilities (cloned from github) $ wadl-tools/bin/normalizeWadl.sh -w {location of your wadl file} -f tree
checker-builder.scala: WADLCheckerBuilder
Transforms normalized WADL using a number of stylesheets into the CheckerFormat (XML). Configuration flags influence the checks that are added to the generated CheckerFormat XML. Stylesheets used by WADLCheckerBuilder include: raxRoles.xsl, builder.xsl
CLI utility: Wadl2Checker -- wadl to a checker format
Optimizations are stored in the core/src/main/resources/xsl/opt
dot-builder.scala: WADLDotBuilder
Create the state machine from the CheckerFormat. The state machine is then used by the validator to validate requests. State machine is created from CheckerFormat XML using the checker2dot stylesheet.
CLI utility: Wadl2Dot -- wadl to visual representation of the state machine