Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.238s · 18.4MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.9s · import 0.219s · 19MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Application
✓ from wadllib.application import Application
✗ from wadl import Application
In wadllib 2.0.0+, the main Application class and other core components moved from the top-level 'wadl' module to 'wadllib.application' and other submodules within 'wadllib'.
WADLFile
✓ from wadllib.wadl import WADLFile
Used for direct interaction with WADL files or XML strings, providing a lower-level interface to the WADL document structure.
This quickstart demonstrates how to load a WADL document from a string, navigate its resources and methods, and inspect their properties using the `wadllib.application.Application` object. It illustrates how to programmatically explore an API's structure as defined by WADL.
from wadllib.application import Application
from io import BytesIO
# A simple example WADL document as a string
wadl_xml = """
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://wadl.dev.java.net/2009/02">
<resources base="http://example.com/api">
<resource path="users">
<method name="GET">
<request/>
<response>
<representation mediaType="application/json"/>
</response>
</method>
<method name="POST">
<request>
<representation mediaType="application/json"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>
<resource path="products/{id}">
<param name="id" type="xsd:int" style="template" required="true"/>
<method name="GET">
<request/>
<response>
<representation mediaType="application/xml"/>
</response>
</method>
</resource>
</resources>
</application>
"""
# Load the WADL from a string (encoded to bytes)
app = Application(wadl_xml.encode('utf-8'))
print(f"API Base URL: {app.resources.base}\n")
print("Available Resources:")
for uri in app.resources:
resource = app.resources[uri]
print(f"- Path: {resource.path} (Full URI: {uri})")
for method in resource.methods:
print(f" - Method: {method.name}")
for response in method.responses:
for rep in response.representations:
print(f" - Responds with: {rep.mediaType}")
# Access a specific resource and its method
users_resource = app.resources.get('http://example.com/api/users')
if users_resource:
get_users_method = users_resource.method_by_name('GET')
if get_users_method:
print(f"\nGET /users method details:")
print(f" HTTP Verb: {get_users_method.name}")
print(f" Request params: {get_users_method.request.params}")
Errors
Common errors & fixes
ImportError: cannot import name 'Application' from 'wadl' (/path/to/wadl/__init__.py)
Attempting to import `Application` using the old import path from `wadllib` 1.x after upgrading to 2.x.
fixChange the import statement to `from wadllib.application import Application`.
SyntaxError: invalid syntax (on a line of the library code itself)
Running `wadllib` 2.0.0+ with an older Python version (e.g., Python 3.7 or earlier), which does not meet the `requires_python >=3.8` requirement.
fixUpgrade your Python environment to version 3.8 or newer to match the library's requirements. Alternatively, downgrade `wadllib` to a 1.x version if compatible with your Python version.
wadllib.exceptions.WADLError: Root element must be 'application'
The provided XML string or file is not a valid WADL document, or its root element is not `<application>`.
fixEnsure the XML document you are passing to `Application()` or `WADLFile()` is a well-formed WADL document, starting with the `<application>` root element and conforming to the WADL schema.
Upgrade
Version history
2.0.0latest on PyPI · released Oct 11, 2024
Audit
Dependencies
No dependency data recorded yet.