Registry / http-networking / wadllib

wadllib

JSON →
library2.0.0pypypi✓ verified 86d ago

wadllib is a Python library designed to help navigate HTTP resources by parsing and interpreting Web Application Description Language (WADL) files. It allows developers to programmatically explore API structures, resources, methods, and parameters defined in a WADL document, providing a machine-readable guide to RESTful services. The current version is 2.0.0, released in January 2024, with active maintenance targeting Python 3.8+.

pip install wadllib
INSTALL
IMPORT
SIG · WADLLIB
W
wadllib
http-networkingpythonv2.0.0
Install
1.9s avg
Import
228ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.238s · 18.4MB
glibc
py 3.103.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}")
Debug
Known issues
breakingThe import paths for core classes like `Application` and `WADLFile` changed significantly in version 2.0.0. Code written for `wadllib` 1.x will fail with `ImportError`.
fix
Update import statements from `from wadl import ...` to `from wadllib.application import ...` or `from wadllib.wadl import ...`.
affects: 2.0.0+
breakingVersion 2.0.0 of `wadllib` dropped support for older Python versions, now requiring Python 3.8 or newer. Running on unsupported Python environments will lead to `SyntaxError` or runtime issues.
fix
Ensure your project's Python interpreter is version 3.8 or higher. Upgrade your Python environment if necessary.
affects: 2.0.0+
gotchawadllib strictly adheres to the WADL specification (2009/02). Malformed or non-compliant WADL files, even if partially readable by humans, may lead to parsing errors (`WADLError`) or unexpected behavior.
fix
Validate your WADL document against the official WADL schema. Ensure all elements and attributes conform to the specification to prevent parsing issues.
affects: All
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.
fix
Change 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.
fix
Upgrade 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>`.
fix
Ensure 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.

Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
wadllib — pip install wadllib · libregistry