Postman collection parser for python
Project description
postmanparser
Introduction
Postman collection parser written in python3 to extract HTTP requests/responses. Currently supports reading JSON schema two ways
- Read from
.json
file - Fetch from url where schema is exposed
Installation
-
Using pip
pip install postmanparser
-
Using poetry
poetry add postmanparser
Getting Started
Parsing API Schema
You can parse API schema from file or from url as below.
- From file
from postmanparser import Collection
collection = Collection()
collection.parse_from_file("path/to/postman/schema.json")
- From url
from postmanparser import Collection
collection = Collection()
collection.parse_from_url("http://example.com/schema")
URL should be a GET
request.
postmanparser also validates for the required fields mentioned by postman schema documentation which is available at https://schema.postman.com/
Reading the data
Postman collection contains group of requests and one or more folders having group of requests and/or nested folders in it.
You can access requests in the collections as shown in below.
for item in collection.item:
if isinstance(item, ItemGroup):
continue #skip folders
print(item.request)
item.request
could be a string or of type Request
with all the attributes of requests according to schema.
Validation
If schema found to be invalid following exception will be thrown.
MissingRequiredFieldException
InvalidPropertyValueException
InvalidObjectException
Schema Support
postmanparser is still in early stages and will be updated with missing schema components soon.
Version
postmanparser supports collection schema v2.0.0 and v2.1.0.
Object support
postmanparser currently does not support parsing of following objects. Might be added in future.
- events
- protocolProfileBehavior
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for postmanparser-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 540fcc496cee9fa0ee6ebec4c47bfea368fde5200e177b064c56683fb7fb4635 |
|
MD5 | c5857ff904579b819c9361f576590f43 |
|
BLAKE2b-256 | 843ed7d95c295db742e0dd84760377fbce5d07258d6ba1f70aee41a55421a64e |