Skip to main content

Import WADL descriptions

WADL (Web Application Description Language, a 2009 W3C member submission) is the XML REST description that came before OpenAPI. It is still served by Jersey and other JAX-RS back-ends (/application.wadl) and is still common in government and enterprise services. A WADL document lists resources with nested resource paths, the HTTP methods on each, their params and the representations they send and return, with XML Schema grammars for the bodies. The WADL importer (wadl) reads it into the Catalog, so the service can be searched, versioned, diffed and linted like any other catalog item. It also gives you a direct path to OpenAPI.

What you can import​

A WADL document in the http://wadl.dev.java.net/2009/02 namespace (the older http://wadl.dev.java.net/ns/wadl namespace is also accepted):

<application xmlns="http://wadl.dev.java.net/2009/02"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.com/library">
<grammars>
<xsd:schema targetNamespace="http://example.com/library">
<xsd:element name="loan" type="tns:Loan"/>
<xsd:complexType name="Loan">
<xsd:sequence>
<xsd:element name="id" type="xsd:string"/>
<xsd:element name="note" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</grammars>
<resource_type id="item">
<param name="loanId" style="template" type="xsd:string"/>
<method name="GET" id="getLoan">
<response status="200 404">
<representation mediaType="application/xml" element="tns:loan"/>
</response>
</method>
</resource_type>
<resources base="https://library.example.com/api/">
<resource path="loans">
<resource path="{loanId}" type="#item"/>
</resource>
</resources>
</application>

WADL's reuse is resolved as if it had been written inline: a method href="#id", a param href="#id", a representation href="#id", and a resource's type="#a #b" (the resource_types whose params, methods and child resources it takes on). Only references to elements in the same document (#id) are followed. An external WADL is never fetched, and a reference that names nothing is reported by the wadl.reference-resolved rule rather than guessed at.

Grammars can be written inline or pulled in with <grammars><include href="…"/>. To bring an included schema along, upload the WADL and its .xsd together as a .zip or a file set.

Import it​

  1. Go to Bring in → Catalog and click "Import to catalog" (see the import wizard).
  2. On Source, choose File and drop the .wadl file (try apiome-ui/examples/wadl/06-task-tracker.wadl). You can also choose URL and enter the service's application.wadl address, or choose Paste and paste the document.
  3. On Detect & route, Apiome reports Auto-detected: WADL (wadl) and routes it to the Catalog.
  4. On Quality, review the lint findings and click "Import".

Over the API, send the document to the import endpoints with the source kind wadl; see Import sources. From the CLI:

apiome import wadl ./06-task-tracker.wadl

The six examples in apiome-ui/examples/wadl/ cover a bookstore, a minimal status ping, a nested catalog, every param style in one file, a news-search service and a task tracker.

What Apiome reads​

In the documentBecomes
Each method of each resource (nested paths joined)An operation keyed VERB /path, named by the method's id
A param with style template, query or headerA path, query or header parameter; required, default, repeating (a list) and its option values (an enum) are kept
A param with style matrix or plainA path or query parameter, its WADL style kept in wadl_style so an export writes it back the same way
A request's representationsThe request message: the grammar element it names and every mediaType
Each code of a response's status listA response message with that status, its grammar element and its media types
Each grammar complexTypeA record type: each sequence element is a field, optional when minOccurs="0" or nillable, and a list when maxOccurs is above 1 or unbounded (the bounds become min_items / max_items)
A named simpleType with enumerationsAn enum type
A named simpleType without enumerationsIts base type (the simple type's name is kept in wadl_type)
resources/@baseThe item's server

Versions and changes​

Import a newer WADL into the same item to add a version. A WADL service validates its XML against the grammars, so the comparison grades changes the way XML Schema does: a sequence is ordered, a missing required element fails validation, and an occurrence bound is enforced.

ChangeSeverityRule
A method gains a required param, or a param became requiredBreakingwadl.parameter-added-required, wadl.parameter-made-required
A param's type changedBreakingwadl.parameter-type-changed
A method gains an optional param, or a param became optionalSafewadl.parameter-added-optional, wadl.parameter-made-optional
A param is removedDangerous: callers that still send it may be rejectedwadl.parameter-removed
An option value removed / addedBreaking / Safewadl.parameter-option-removed, wadl.parameter-option-added
A representation's mediaType removed / addedBreaking / Safewadl.media-type-removed, wadl.media-type-added
A representation names a different elementBreakingwadl.representation-type-changed
A sequence gains a required / optional elementBreaking / Safewadl.element-added-required, wadl.element-added-optional
An element's type changed, or it became repeatedBreakingwadl.element-type-changed
An element became requiredBreakingwadl.element-made-required
An element became optionalDangerous: readers may now find it missingwadl.element-made-optional
Elements swapped placesBreaking: a sequence is validated in orderwadl.element-reordered
An element moved only because a sibling was added or removedSafe: the sibling's change is graded on its ownwadl.element-shifted
minOccurs rose or maxOccurs fellBreakingwadl.occurs-narrowed
minOccurs fell or maxOccurs roseDangerouswadl.occurs-widened
An enumeration value removed / addedBreaking / Dangerouswadl.enum-value-removed, wadl.enum-value-added

A removed method, response, type or element is breaking, and any other addition is safe.

Lint​

The Quality step and the item's Lint & score tab add the wadl rules on top of the common ones. Several of them flag what will not carry over cleanly to OpenAPI:

RuleSeverityFlags
wadl.reference-resolvedErrorAn href or resource type that names no element of the document, or names an external WADL
wadl.template-param-declaredErrorA {name} in a path with no template param to give it a type
wadl.template-param-usedWarningA template param that no {name} in the path uses
wadl.method-id-uniqueErrorTwo methods with the same id
wadl.method-id-presentInfoA method without an id: the OpenAPI migration has to invent an operationId
wadl.method-name-standardWarningA method name that is not a standard HTTP method; OpenAPI 3.1 has no slot for it
wadl.body-on-safe-methodWarningA GET, HEAD or DELETE whose request carries a representation
wadl.response-declaredWarningA method with no response
wadl.response-status-validWarningA status that is not a three-digit HTTP code
wadl.type-resolvedWarningA type that is neither an XSD built-in nor declared by the grammars, such as an include that was not uploaded
wadl.representation-typedInfoAn XML or JSON representation with no element; it converts as an untyped body
wadl.representation-media-typeInfoA typed representation with no mediaType
wadl.base-uri-presentInfoNo resources/@base, so the OpenAPI document has no server

Migrate to OpenAPI​

Converting a WADL catalog item is the migration. Go to Bring in → Catalog, open the item and click "Convert to OpenAPI Project" (see Convert a catalog item to OpenAPI). The wadl conversion pack carries over:

  • each resource path and method as an OpenAPI path and operation, and each method id as its operationId. An id that two methods share is replaced by a generated one, so the document stays valid;
  • each template, query and header param as a parameter, with its option values as an enum;
  • each representation as request or response content under its media type, referencing the grammar type, and each status code as its own response;
  • each grammar type as a schema under components.schemas, renamed to a name OpenAPI allows (http://example.com/library.Loan becomes library.Loan);
  • resources/@base as the server.

What does not carry over: a representation without a grammar element converts as an untyped body, and a method whose name is not a standard HTTP verb has no OpenAPI 3.1 slot. Fix the wadl.representation-typed and wadl.method-name-standard findings before converting.

Export​

A WADL item writes back out as WADL (with its grammar as a separate .xsd, or in one file) through the WADL target; see Export a spec. Param styles, option values, every media type and the elements' occurrence survive the round trip.

When an import is refused​

MessageWhyWhat to do
Malformed XML: …The document is not well-formed XML (a mismatched or unclosed tag)Fix the XML at the line and column given
No WADL types or resources foundThe application declares no grammar type and no resource methodAdd the resources
Content does not appear to be a WADL documentThere is no application root in a WADL namespace (a WSDL, or a UTF-16 file)Pick the right format, or save the file as UTF-8
INPUT_UNSAFE_CONSTRUCTThe document declares a DTD or entitiesRemove the <!DOCTYPE>; WADL never needs one