Skip to content

"default" collection variable type fails schema validation #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mharmon-fas opened this issue Feb 4, 2025 · 0 comments
Open

"default" collection variable type fails schema validation #207

mharmon-fas opened this issue Feb 4, 2025 · 0 comments

Comments

@mharmon-fas
Copy link

Bug description
When you define collection variables and export the collection as v2.0 or v2.1 schema formats they do not pass schema validation tests. The issue seems to be that the variables "type" field is not in the accepted list as per the schema.

From: https://schema.postman.com/collection/json/v2.1.0/draft-07/collection.json (L1058):

"type": {
  "description": "A variable may have multiple types. This field specifies the type of the variable.",
  "type": "string",
  "enum": [
    "string",
    "boolean",
    "any",
    "number"
    ]
},

However a collection exported from the postman app sets all variables to type "default" from my experience. I have not found a way to edit the types of these variables native to the application.

Steps to Reproduce

  1. Create a postman collection on the app
  2. Add some collection level variable
  3. Save the collection and export it as v2.0 or v2.1
  4. Run a schema validation against it to see the failure (python code provided below)
  5. Edit the exported schema file - at the bottom find your collection variable(s) - change the "type" field for each of the variables to one of the allowed types (string, boolean, any, number)
  6. Run a schema validation against it

Expected Behavior

An exported postman collection should pass a schema validation check.

Validation Code

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

schema = requests.get('https://schema.postman.com/collection/json/v2.1.0/draft-07/collection.json').json()

with open("C:\\Users\\matt\\Downloads\\Demo.postman_collection.json", 'r') as f:
    test_input = json.load(f)
    print(test_input)

try:
    validate(test_input, schema)

except ValidationError:
    print('It is not a valid collection!')
else:
    print('It is a valid collection!')

Attachments

I have attached two postman collections, the one tagged with 'fixed' has the type fields edited. It will pass the schema validation.

Demo.postman_collection.json
Demo.postman_collection_fixed.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant