This submodule contains code for fetching/parsing URLs.


exception prance.util.url.ResolutionError[source]

Bases: exceptions.LookupError


prance.util.url.absurl(url, relative_to=None)[source]

Turn relative file URLs into absolute file URLs.

This is necessary, because while JSON pointers do not allow relative file URLs, Swagger/OpenAPI explicitly does. We need to make relative paths absolute before passing them off to jsonschema for verification.

Non-file URLs are left untouched. URLs without scheme are assumed to be file URLs.

  • url (str/tuple) – The input URL.
  • relative_to (str/tuple) – [optional] The URL to which the input URL is relative.

The output URL, parsed into components.

Return type:



Fetch the URL and parse the contents.

If the URL is a file URL, the format used for parsing depends on the file extension. Otherwise, YAML is assumed.

Parameters:url (tuple) – The url, parsed as returned by absurl above.
Returns:The parsed file.
Return type:dict

Return the resource part of a parsed URL.

The resource part is defined as the part without query, parameters or fragment. Just the scheme, netloc and path remains.

Parameters:url (tuple) – A parsed URL
Returns:The resource part of the URL
Return type:str