Giter Site home page Giter Site logo

postmanlabs / schemas Goto Github PK

View Code? Open in Web Editor NEW
40.0 16.0 39.0 1.56 MB

Repository of all schemas for JSON structures compatible with Postman (such as the Postman Collection Format)

Home Page: https://schema.getpostman.com/

License: Apache License 2.0

JavaScript 97.20% Shell 2.80%

schemas's Introduction

Postman Schemas

Repository of all schemas for JSON structures compatible with Postman (such as the Postman Collection Format). The schemas are also hosted online, at schema.getpostman.com.

Usage

All the schemas in this repository are valid JSON Schemas, compliant with the JSON-Schema, Draft 4. As such, they can be used with a number of tools to validate arbitrary JSON blobs, as show below:

Examples: JavaScript

var https = require('https'),
    validate = require('is-my-json-valid');

var input = {
    /* JSON of a collection V1 */
};

// we fetch the schema from server and when it is received, 
// validate our input JSON against it.
https.get('https://schema.getpostman.com/json/collection/v1/', function (response) {
    var body = '';

    response.on('data', function (d) {
        body += d;
    });

    response.on('end', function () {
        var validate = validator(JSON.parse(body));
        console.log(validate(input) ? 'It is a valid collection!' : 'It is not a valid collection!');
    });
});
var https = require('https'),
    tv4 = require('tv4');

var input = {
    /* JSON of a collection V1 */
};

// we fetch the schema from server and when it is received,
// validate our input JSON against it.
https.get('https://schema.getpostman.com/json/collection/v1/', function (response) {
    var body = '';

    response.on('data', function (d) {
        body += d;
    });

    response.on('end', function () {
        var result = tv4.validate(input, JSON.parse(body));
        console.log((result) ? 'It is a valid collection!' : 'It is not a valid collection!');
    });
});

Example: Python

import requests  # make sure this is installed
from jsonschema import validate
from jsonschema.exceptions import ValidationError

schema = requests.get('https://schema.getpostman.com/json/collection/v1/').json()

test_input = {}  # Whatever needs to be validated.

try:
    validate(test_input, schema)
except ValidationError:
    print 'It is not a valid collection!'
else:
    print 'It is a valid collection!'

schemas's People

Contributors

codenirvana avatar coditva avatar czardoz avatar greenkeeper[bot] avatar jibi-abraham avatar jmini avatar kunagpal avatar oswish avatar shamasis avatar vikicoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

schemas's Issues

Confusion over schema version

Checking through the json generated from Postman, I saw that it has the schema url at https://schema.getpostman.com/json/collection/v2.1.0/collection.json which is a v4 schema. The README itself mentions that they conform to v4 schema. But when I visit the website at https://schema.getpostman.com/ and click the link to the schema, I get a v7 schema. I checked the generated collection json with both v4 and v7 and it passes for both the versions (at least for my collection). As such I am a bit confused as to which version of json-schema is actually implemented for the schema. Any light on this is highly appreciated.

Response can contains a "name" attribute

When you save a response inside an Item in your collection. You can see it in the UI using the "Examples" menu:

Postman Examples menu

Then you see that there is a "Name" field and you can modify it:
Editing an Example in Postman

The corresponding exported collection is:

{
	"info": {
		"_postman_id": "8eb2ed98-751a-4cb1-802e-3a68fc75aece",
		"name": "example",
		"description": "This is an example",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "Echo",
			"protocolProfileBehavior": {
				"strictSSL": true
			},
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "https://postman-echo.com/get?foo1=bar1&foo2=bar2",
					"protocol": "https",
					"host": [
						"postman-echo",
						"com"
					],
					"path": [
						"get"
					],
					"query": [
						{
							"key": "foo1",
							"value": "bar1"
						},
						{
							"key": "foo2",
							"value": "bar2"
						},
						{
							"key": "foo3",
							"value": "bar3",
							"disabled": true
						}
					]
				}
			},
			"response": [
				{
					"name": "An example response",
					"originalRequest": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "https://postman-echo.com/get?foo1=bar1&foo2=bar2",
							"protocol": "https",
							"host": [
								"postman-echo",
								"com"
							],
							"path": [
								"get"
							],
							"query": [
								{
									"key": "foo1",
									"value": "bar1"
								},
								{
									"key": "foo2",
									"value": "bar2"
								},
								{
									"key": "foo3",
									"value": "bar3",
									"disabled": true
								}
							]
						}
					},
					"status": "OK",
					"code": 200,
					"_postman_previewlanguage": "json",
					"header": [
						{
							"key": "Date",
							"value": "Tue, 08 Sep 2020 08:04:27 GMT"
						},
						{
							"key": "Content-Type",
							"value": "application/json; charset=utf-8"
						},
						{
							"key": "Content-Length",
							"value": "419"
						},
						{
							"key": "Connection",
							"value": "keep-alive"
						},
						{
							"key": "ETag",
							"value": "W/\"1a3-vwFawOO37OnYQGNtBFLTPixH31M\""
						},
						{
							"key": "Vary",
							"value": "Accept-Encoding"
						},
						{
							"key": "set-cookie",
							"value": "sails.sid=s%3ApyF9hzzYC5NjV7ogxvM7BNPFymP9Ls8H.DK8FFg7FOhLkO1RfjI9xv%2FzSGxGFsmnZG4lzuU2aUFQ; Path=/; HttpOnly"
						}
					],
					"cookie": [],
					"body": "{\n    \"args\": {\n        \"foo1\": \"bar1\",\n        \"foo2\": \"bar2\"\n    },\n    \"headers\": {\n        \"x-forwarded-proto\": \"https\",\n        \"x-forwarded-port\": \"443\",\n        \"host\": \"postman-echo.com\",\n        \"x-amzn-trace-id\": \"Root=1-5f573b0b-f2778ce614aa4802e5e31d63\",\n        \"user-agent\": \"PostmanRuntime/7.26.3\",\n        \"accept\": \"*/*\",\n        \"cache-control\": \"no-cache\",\n        \"postman-token\": \"1818d9cc-912f-4a22-bc79-a0a8d653d3c1\",\n        \"accept-encoding\": \"gzip, deflate, br\"\n    },\n    \"url\": \"https://postman-echo.com/get?foo1=bar1&foo2=bar2\"\n}"
				}
			]
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"id": "d9560c6b-a476-48b8-9956-8841f7b1477a",
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"id": "5a557916-971a-4b7a-ab08-13581ecf2a71",
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"protocolProfileBehavior": {}
}

As you can see on line 46, there is a name attribute containing the value.

But the schema doesn't describes this name attribute, inside the properties map:

item-group can contains a "_postman_isSubFolder" attribute

When an Item into a sub-sub folder (a.k.a item-group):

Sub-sub folder

The corresponding exported collection is:

{
	"info": {
		"_postman_id": "4e034bd9-dc3b-427b-ba77-83a8ecc9cdc8",
		"name": "example",
		"description": "This is an example",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "foo",
			"item": [
				{
					"name": "bar",
					"item": [
						{
							"name": "Echo",
							"protocolProfileBehavior": {
								"strictSSL": true
							},
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "https://postman-echo.com/get",
									"protocol": "https",
									"host": [
										"postman-echo",
										"com"
									],
									"path": [
										"get"
									]
								}
							},
							"response": []
						}
					],
					"protocolProfileBehavior": {},
					"_postman_isSubFolder": true
				}
			],
			"event": [],
			"protocolProfileBehavior": {}
		}
	],
	"event": [],
	"protocolProfileBehavior": {}
}

As you can see on line 39, there is a _postman_isSubFolder attribute (boolean value).

But the schema doesn't describes this _postman_isSubFolder attribute, inside the properties map:

Allow `request.tests` to permit "incomplete" tests

It would be useful to be able to mark tests incomplete, similar to: https://phpunit.de/manual/current/en/incomplete-and-skipped-tests.html. Such tests would not cause a "fail" result for a test collection, but they would be highlighted for future attention. In Postman or Newman's case, this could be a yellow icon or a CLI warning message, respectively.

The use case is for continuous integration, when adding tests to features that have preexisting invalid behavior (for example, the incorrect response code). A failure result is not useful, because it obscures new "real" failures for incoming changes. A passing test is also not useful, because it tests invalid results and provide no indication of a problem.

Obviously this is more than a schema change; I can make a similar feature request wherever is appropriate for Newman.

Postman client spit out invalid collection according to the schemas

If you export the postman echo collection from the postman client, it violate the schema in multiple ways.
For example it violates the fact that, in the version 2.0.0 of the spec, items are not allowed to have a name.

Whatever the client export doesn't respect any of your schemas which makes those schemas absolutely useless IMO...

When is the content synchronized with https://schema.getpostman.com/ ?

I am looking at commit 03341ea that documents the options attribute of request body.

But this is not present on the online documentation:
https://schema.getpostman.com/collection/json/v2.1.0/draft-07/docs/index.html

schema.getpostman.com Screenshot

The JSON definition is also outdated:
https://schema.getpostman.com/collection/json/v2.1.0/draft-07/collection.json

Is there a sync mechanism?
How do I get the single collection.json file based on the content of this repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.