Merge pull request #448 from postmanlabs/fix/getOptionsAndValidationTests

Fix/get options and validation tests
This commit is contained in:
Luis Tejeda
2022-01-20 15:15:50 -06:00
committed by GitHub
44 changed files with 5597 additions and 521 deletions

View File

@@ -129,7 +129,21 @@ function getConcreteSchemaUtils({ type, data }) {
return concreteUtils;
}
/**
* Filter the options by the version provided by the user
* @param {array} options The options to be filtered
* @param {string} version The version that will be used
* @returns {array} the filtered options related to the version used
*/
function filterOptionsByVersion(options, version) {
options = options.filter((option) => {
return option.supportedIn.includes(version);
});
return options;
}
module.exports = {
getSpecVersion,
getConcreteSchemaUtils
getConcreteSchemaUtils,
filterOptionsByVersion
};

View File

@@ -1,9 +1,37 @@
const _ = require('lodash');
const { filterOptionsByVersion } = require('./common/versionUtils');
const _ = require('lodash'),
VALID_MODES = ['document', 'use'],
VERSION30 = '3.0',
VERSION31 = '3.1',
VALID_VERSIONS = [VERSION30, VERSION31];
/**
* Takes a list of arguments and resolve them acording its content
* @param {array} args The arguments that will be resolved
* @returns {array} The list of arguments after have been resolved
*/
function handleArguments(args) {
let mode = 'document',
criteria = {},
version = VERSION30;
args.forEach((argument) => {
if (typeof argument === 'object' && Object.keys(argument).length > 0) {
criteria = argument;
}
else if (VALID_MODES.includes(argument)) {
mode = argument;
}
else if (VALID_VERSIONS.includes(argument)) {
version = argument;
}
});
return { mode, criteria, version };
}
module.exports = {
// default options
// if mode=document, returns an array of name/id/default etc.
/**
* name - human-readable name for the option
* id - key to pass the option with
@@ -19,14 +47,15 @@ module.exports = {
* @param {Object} criteria Decribes required criteria for options to be returned. can have properties
* external: <boolean>
* usage: <array> (Array of supported usage type - CONVERSION, VALIDATION)
* @param {string} version The specification version provided
* @returns {mixed} An array or object (depending on mode) that describes available options
*/
getOptions: function(mode = 'document', criteria = {}) {
getOptions: function(mode = 'document', criteria = {}, version = '3.0') {
// Override mode & criteria if first arg is criteria (objects)
if (typeof mode === 'object') {
criteria = mode;
mode = 'document';
}
const resolvedArguments = handleArguments([mode, criteria, version]);
mode = resolvedArguments.mode;
criteria = resolvedArguments.criteria;
version = resolvedArguments.version;
let optsArray = [
{
@@ -39,7 +68,8 @@ module.exports = {
' If “Fallback” is selected, the request will be named after one of the following schema' +
' values: `description`, `operationid`, `url`.',
external: true,
usage: ['CONVERSION', 'VALIDATION']
usage: ['CONVERSION', 'VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Set indent character',
@@ -49,7 +79,8 @@ module.exports = {
availableOptions: ['Space', 'Tab'],
description: 'Option for setting indentation character',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Collapse redundant folders',
@@ -59,7 +90,8 @@ module.exports = {
description: 'Importing will collapse all folders that have only one child element and lack ' +
'persistent folder-level data.',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Optimize conversion',
@@ -69,7 +101,8 @@ module.exports = {
description: 'Optimizes conversion for large specification, disabling this option might affect' +
' the performance of conversion.',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Request parameter generation',
@@ -82,7 +115,8 @@ module.exports = {
' [example](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#exampleObject)' +
' in the schema.',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Response parameter generation',
@@ -95,7 +129,8 @@ module.exports = {
' [example](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#exampleObject)' +
' in the schema.',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Folder organization',
@@ -105,7 +140,8 @@ module.exports = {
availableOptions: ['Paths', 'Tags'],
description: 'Select whether to create folders according to the specs paths or tags.',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Enable Schema Faking',
@@ -114,7 +150,8 @@ module.exports = {
default: true,
description: 'Whether or not schemas should be faked.',
external: false,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Schema resolution nesting limit',
@@ -125,7 +162,8 @@ module.exports = {
' result in more time to convert collection depending on complexity of specification. (To make sure this' +
' option works correctly "optimizeConversion" option needs to be disabled)',
external: false,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Include auth info in example requests',
@@ -134,7 +172,8 @@ module.exports = {
default: true,
description: 'Select whether to include authentication parameters in the example request',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Short error messages during request <> schema validation',
@@ -143,7 +182,8 @@ module.exports = {
default: false,
description: 'Whether detailed error messages are required for request <> schema validation operations.',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Properties to ignore during validation',
@@ -154,7 +194,8 @@ module.exports = {
' Must be sent as an array of strings. Valid inputs in the array: PATHVARIABLE, QUERYPARAM,' +
' HEADER, BODY, RESPONSE_HEADER, RESPONSE_BODY',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Whether MISSING_IN_SCHEMA mismatches should be returned',
@@ -164,7 +205,8 @@ module.exports = {
description: 'MISSING_IN_SCHEMA indicates that an extra parameter was included in the request. For most ' +
'use cases, this need not be considered an error.',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Show detailed body validation messages',
@@ -174,7 +216,8 @@ module.exports = {
description: 'Determines whether to show detailed mismatch information for application/json content ' +
'in the request/response body.',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Suggest fixes if available',
@@ -183,7 +226,8 @@ module.exports = {
default: false,
description: 'Whether to provide fixes for patching corresponding mismatches.',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Show Metadata validation messages',
@@ -192,7 +236,8 @@ module.exports = {
default: false,
description: 'Whether to show mismatches for incorrect name and description of request',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Ignore mismatch for unresolved postman variables',
@@ -201,7 +246,8 @@ module.exports = {
default: false,
description: 'Whether to ignore mismatches resulting from unresolved variables in the Postman request',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Enable strict request matching',
@@ -211,7 +257,8 @@ module.exports = {
description: 'Whether requests should be strictly matched with schema operations. Setting to true will not ' +
'include any matches where the URL path segments don\'t match exactly.',
external: true,
usage: ['VALIDATION']
usage: ['VALIDATION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Disable optional parameters',
@@ -220,7 +267,8 @@ module.exports = {
default: false,
description: 'Whether to set optional parameters as disabled',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
},
{
name: 'Keep implicit headers',
@@ -229,7 +277,8 @@ module.exports = {
default: false,
description: 'Whether to keep implicit headers from the OpenAPI specification, which are removed by default.',
external: true,
usage: ['CONVERSION']
usage: ['CONVERSION'],
supportedIn: [VERSION30, VERSION31]
}
];
@@ -251,6 +300,7 @@ module.exports = {
if (mode === 'use') {
// options to be used as default kv-pairs
let defOptions = {};
optsArray = filterOptionsByVersion(optsArray, version);
_.each(optsArray, (opt) => {
// special handling for indent character as in documentation it states `Tab` and `Space`
// but for the generation mode, we need actual values

View File

@@ -0,0 +1,219 @@
{
"openapi": "3.1.0",
"info": {
"version": "1.0.0",
"title": "Path Variable issues",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/send-sms.{format}": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "format",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
}
]
}
},
"/some/{path}": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "path",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
}
]
}
},
"/new/{path}.{new-path-variable-1}": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "path",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"examples": ["send-email"]
}
},
{
"name": "new-path-variable-1",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["object"],
"properties": {
"R": { "type": ["integer"], "examples": [100] },
"G": { "type": ["integer"], "examples": [200] },
"B": { "type": ["integer"], "examples": [150] }
}
}
}
]
}
},
"/next/{path}/{new-path-variable}": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "path",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
},
{
"name": "new-path-variable",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
}
]
}
},
"/anotherpath/{path}/{new-path-variable-2}.{onemore}": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "path",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
},
{
"name": "new-path-variable-2",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["array"],
"items": {
"type": ["string"],
"examples": ["exampleString"]
}
}
},
{
"name": "onemore",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
}
]
}
},
"/{path}({new-path-variable}={onemore})": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "path",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
},
{
"name": "new-path-variable",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
},
{
"name": "onemore",
"in": "path",
"description": "description",
"required": true,
"schema": {
"type": ["string"],
"pattern": "json|xml",
"examples": ["json"]
}
}
]
}
}
}
}

View File

@@ -0,0 +1,21 @@
openapi: 3.1.0
info:
title: Swagger Petstore
description: des
version: 1.0.0
paths:
/get:
get:
summary: Some API
responses:
'200':
description: Some description
content:
application/json:
schema:
type:
- array
items:
type:
- string
examples: {}

View File

@@ -0,0 +1,152 @@
{
"openapi": "3.1.0",
"info": {
"version": "1.0.0",
"title": "#160",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/pets": {
"servers": [
{
"url": "http://petstore.swagger.io:{port}/{basePath}",
"variables": {
"port": {
"enum": [
"8443",
"443"
],
"default": "8443"
},
"basePath": {
"default": "v2"
}
}
}
],
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "limit",
"in": "query",
"description": "How many items to return at one time (max 100)",
"required": false,
"schema": {
"type": ["integer"],
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "A paged array of pets",
"headers": {
"x-next": {
"description": "A link to the next page of responses",
"schema": {
"type": ["string"]
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pets"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"summary": "Create a pet",
"operationId": "createPets",
"tags": [
"pets"
],
"responses": {
"201": {
"description": "Null response"
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"type": ["object"],
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": ["integer"],
"format": "int64"
},
"name": {
"type": ["string"]
},
"tag": {
"type": ["string"]
}
}
},
"Pets": {
"type": ["array"],
"items": {
"$ref": "#/components/schemas/Pet"
}
},
"Error": {
"type": ["object"],
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": ["integer"],
"format": "int32"
},
"message": {
"type": ["string"]
}
}
}
}
}
}

View File

@@ -0,0 +1,32 @@
openapi: "3.1.0"
info:
version: "1.0.0"
title: "Sample API"
paths:
/path1:
post:
parameters:
- in: header
name: access_token
description: Access token
schema:
type:
- string
examples:
- X-access-token
responses:
200:
description: 200 Success
400:
description: 400 Bad Request
401:
description: 401 Unauthorized
403:
description: 403 Forbidden
404:
description: 404 Not Found
500:
description: 500 Internal Server Error

View File

@@ -0,0 +1,72 @@
openapi: 3.1.0
info:
version: 1.0
title: Demo API dodo
paths:
/api:
get:
summary: 'Demo invalid type'
responses:
'200':
description: 'Cannot use type boolean'
content:
application/json:
schema:
type:
- object
properties:
nominmax:
type:
- array
items:
type:
- string
exmaples:
- hello
nomin:
type:
- array
maxItems: 5
items:
type:
- string
exmaples:
- hello
nomax:
type:
- array
minItems: 4
items:
type:
- string
exmaples:
- hello
minmax:
type:
- array
minItems: 3
maxItems: 5
items:
type:
- string
exmaples:
- hello
max:
type:
- array
minItems: 30
maxItems: 40
items:
type:
- string
exmaples:
- hello
min:
type:
- array
minItems: 1
items:
type:
- string
exmaples:
- hello

View File

@@ -0,0 +1,128 @@
openapi: 3.1.0
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type:
- integer
format: int32
responses:
"200":
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type:
- string
content:
application/json:
schema:
properties:
newprop:
type:
- array
items:
required:
- id
- name
properties:
id:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string
default:
description: unexpected error
content:
application/json:
schema:
required:
- code
- message
properties:
code:
type:
- integer
format: int32
message:
type:
- string
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
"201":
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
properties:
data:
type:
- array
items:
oneOf:
- $ref: "#/paths/~1pets/get/responses/200/content/applicati\
on~1json/schema/properties/newprop"
- $ref: "#/paths/~1pets/get/responses/default/content/appli\
cation~1json/schema"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string
Pets:
type:
- array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type:
- integer
format: int32
message:
type:
- string

View File

@@ -0,0 +1,252 @@
{
"item": [
{
"id": "e3a46ab9-3e5d-4209-8a1c-3c2d9b51d488",
"name": "composite schema with anyOf keyword",
"request": {
"name": "composite schema with anyOf keyword",
"description": {},
"url": {
"path": [
"pets",
"anyOf"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"objectType\": \"a string\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"response": [
{
"id": "586bc4d3-3e99-4996-ae41-492b9528a09c",
"name": "ok",
"originalRequest": {
"url": {
"path": [
"pets",
"anyOf"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"objectType\": \"a string\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
},
{
"id": "07e822eb-3b75-44ca-8f95-47a5d529e64d",
"name": "composite schema with oneOf keyword",
"request": {
"name": "composite schema with oneOf keyword",
"description": {},
"url": {
"path": [
"pets",
"oneOf"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw":"{\n \"objectType2\": \"a string\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"response": [
{
"id": "8e4bffe2-c6b9-490a-9d65-3d16997d54fa",
"name": "ok",
"originalRequest": {
"url": {
"path": [
"pets",
"oneOf"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw":"{\n \"objectType2\": \"a string\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
},
{
"id": "b7c13480-5b84-4acc-9749-1b9949f99a7d",
"name": "composite schema with allOf keyword",
"request": {
"name": "composite schema with allOf keyword",
"description": {},
"url": {
"path": [
"pets",
"allOf"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"objectType\": \"not an integer\",\n \"objectType2\": \"prop named objectType2\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"response": [
{
"id": "292a946f-874a-4274-a6a2-66715f3b37f3",
"name": "ok",
"originalRequest": {
"url": {
"path": [
"pets",
"allOf"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"objectType\": \"not an integer\",\n \"objectType2\": \"prop named objectType2\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
}
],
"event": [],
"variable": [
{
"type": "string",
"value": "http://petstore.swagger.io/v1",
"key": "baseUrl"
}
],
"info": {
"_postman_id": "2cccac2f-9007-4df9-ae5e-a6630ad8fc3f",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,86 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets/anyOf:
post:
summary: composite schema with anyOf keyword
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/anyOfExample"
responses:
default:
description: ok
/pets/oneOf:
post:
summary: composite schema with oneOf keyword
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/oneOfExample"
responses:
default:
description: ok
/pets/allOf:
post:
summary: composite schema with allOf keyword
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/allOfExample"
responses:
default:
description: ok
components:
schemas:
anyOfExample:
anyOf:
- $ref: "#/components/schemas/schema1"
- $ref: "#/components/schemas/schema2"
oneOfExample:
oneOf:
- $ref: "#/components/schemas/schema1"
- $ref: "#/components/schemas/schema3"
allOfExample:
allOf:
- $ref: "#/components/schemas/schema1"
- $ref: "#/components/schemas/schema3"
schema1:
type:
- object
required:
- objectType
properties:
objectType:
type:
- integer
example: 4321
schema2:
type:
- object
required:
- objectType
properties:
objectType:
type:
- string
example: prop named objectType
schema3:
type:
- object
required:
- objectType2
properties:
objectType2:
type:
- string
example: prop named objectType2

View File

@@ -0,0 +1,102 @@
{
"item": [
{
"id": "01cf6ca9-c708-433b-9713-eb11be11f4d8",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "2359399f-6127-457f-afdf-ac74c1c35717",
"name": "List all pets",
"request": {
"name": "List all pets",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"key": "Content-Type",
"value": "application/vnd.github+json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"id\": true,\n \"name\": \"ea adip\",\n \"tag\": \"proident Duis aliquip quis\"\n}"
}
},
"response": [
{
"id": "41dec372-09c2-44b9-958b-6d0897038947",
"name": "content with optional params media type",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "<integer>"
}
],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"id\": -74679749,\n \"name\": \"ea adip\",\n \"tag\": \"proident Duis aliquip quis\"\n}"
}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
}
],
"body": "{\n \"id\": 1234,\n \"name\": 1234,\n \"tag\": \"proident Duis aliquip quis\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "8e92c978-8d41-4a4e-8d63-98d3bc0572d2",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,44 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
post:
summary: List all pets
operationId: listPets
tags:
- pets
requestBody:
content:
application/vnd.github+json:
schema:
$ref: "#/components/schemas/Pet"
responses:
'200':
description: content with optional params media type
content:
'application/json; charset=utf-8':
schema:
$ref: "#/components/schemas/Pet"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string

View File

@@ -0,0 +1,118 @@
openapi: 3.1.0
info:
title: Products
description: This is the OpenAPI for the Union Fashion product catalog.
version: '1.0'
servers:
- url: '{{baseUrl}}'
paths:
/products:
post:
summary: Add Productz
description: Creates a new productz.
operationId: addProduct
tags:
- Products
requestBody:
description: A product schema.
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
example:
category: Jeans
brand: Union
color: black
gender: m
unitPrice: 49.99
unitSalePrice: 29.99
security:
- api_key: []
responses:
default:
description: 'Sample desc.'
components:
securitySchemes:
api_key:
type: apiKey
name: x-api-key
in: header
schemas:
Products:
type:
- array
items:
$ref: '#/components/schemas/Product'
Product:
title: Product
required:
- identifier
- name
type:
- object
properties:
identifier:
type:
- string
name:
type:
- string
description:
type:
- string
image:
type:
- string
url:
type:
- string
brand:
type:
- string
category:
type:
- string
color:
type:
- string
logo:
type:
- string
manufacturer:
type:
- string
material:
type:
- string
model:
type:
- string
releaseDate:
type:
- string
sku:
type:
- string
width:
type:
- string
weight:
type:
- string
depth:
type:
- string
height:
type:
- string
example:
id: XYZ-JEAN-123
category: Jeans
brand: Union
color: black
gender: m
unitPrice: 49.99
unitSalePrice: 29.99
tags:
- name: Products
description: A product object.

View File

@@ -0,0 +1,134 @@
{
"item": [
{
"id": "448f9fe2-0057-4d55-a369-80d41162b8a6",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "6ee42234-271d-490c-a23a-50b70a57142c",
"name": "List all pets",
"request": {
"name": "List all pets",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"description": "How many items to return at one time (max 100)",
"key": "limit",
"value": "89178631"
}
],
"variable": []
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "d491ab71-8cde-4fd8-9538-7896929c2309",
"name": "A paged array of pets",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "<integer>"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"description": "A link to the next page of responses",
"key": "x-next",
"value": "velit ea si"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "[\n {\n \"id\": -14143765,\n \"name\": \"deserunt in\",\n \"tag\": \"consectetur cupidatat\"\n },\n {\n \"id\": -65226018,\n \"name\": \"ex consectetur eu in\",\n \"tag\": \"laborum mollit officia Ut\"\n }\n]",
"cookie": [],
"_postman_previewlanguage": "json"
},
{
"id": "23ad8e8e-a752-4a5d-905e-2b63f04fb7ea",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "<integer>"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": 41499321,\n \"message\": \"dolore\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "a60fcbcc-ec53-4cd7-a4df-7abe60ebeb84",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,83 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
# below param is empty for testing
-
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type:
- integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type:
- string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type:
- object
required:
- id
- name
properties:
id:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string
Pets:
type:
- array
items:
$ref: "#/components/schemas/Pet"
Error:
type:
- object
required:
- code
- message
properties:
code:
type:
- integer
format: int32
message:
type:
- string

View File

@@ -0,0 +1,163 @@
{
"item": [
{
"id": "6e1e8783-7fae-4902-b764-b8a5c2632139",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "46d9bd4b-c82c-454b-93e5-dcdf64798497",
"name": "Create a pet",
"request": {
"name": "Create a pet",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"description": "",
"key": "Accept",
"value": "application/json"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "",
"key": "header-1",
"value": "not a number"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"id\": 11265533,\n \"name\": \"tempor adipisicin\",\n \"tag\": \"sint culpa veniam\"\n}"
}
},
"response": [
{
"id": "34840c21-65c2-42f6-8a6d-280a4f800849",
"name": "Null response",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"description": "",
"key": "Accept",
"value": "<string>"
},
{
"description": "",
"key": "header-1",
"value": "<integer>"
}
],
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"id\": 11265533,\n \"name\": \"tempor adipisicin\",\n \"tag\": \"sint culpa veniam\"\n}"
}
},
"status": "Created",
"code": 201,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
},
{
"id": "7aaf6fcb-2af9-4c4f-a650-b004101b6cf5",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"description": "",
"key": "Accept",
"value": "<string>"
},
{
"description": "",
"key": "header-1",
"value": "<integer>"
}
],
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"id\": 11265533,\n \"name\": \"tempor adipisicin\",\n \"tag\": \"sint culpa veniam\"\n}"
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": 22640796,\n \"message\": \"aute\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "2d5ffaea-40bd-4f22-8bc7-e951deeacdf6",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,88 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
post:
summary: Create a pet
operationId: createPets
tags:
- pets
parameters:
- name: Accept
in: header
required: false
schema:
type:
- string
- name: header-1
in: header
required: false
schema:
type:
- integer
format: int32
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
'201':
description: Null response
default:
description: unexpected error
headers:
content-type:
description: content-type of response body
required: true
schema:
type:
- string
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type:
- object
required:
- id
- name
properties:
id:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string
Pets:
type:
- array
items:
$ref: "#/components/schemas/Pet"
Error:
type:
- object
required:
- code
- message
properties:
code:
type:
- integer
format: int32
message:
type:
- string

View File

@@ -0,0 +1,260 @@
{
"item": [
{
"id": "9b8ff406-3176-49ca-b91a-e99277130d40",
"name": "searches inventory",
"request": {
"name": "searches inventory",
"description": {
"content": "By passing in the appropriate options, you can search for\navailable inventory in the system\n",
"type": "text/plain"
},
"url": {
"path": [
"inventory",
":searchString"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"description": "number of records to skip for pagination",
"key": "skip",
"value": "71616628"
}
],
"variable": [
{
"description": "pass an optional search string for looking up inventory",
"type": "any",
"value": "magna",
"key": "searchString"
}
]
},
"header": [
{
"description": "maximum number of records to return",
"key": "limit",
"value": "25"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n \"name\": \"Widget Adapter\",\n \"manufacturer\": {\n \"name\": \"ACME Corporation\",\n \"homePage\": \"https://www.acme-corp.com\",\n \"phone\": \"408-867-5309\"\n },\n \"releaseDate\": \"2016-08-29T09:12:33.001Z\"\n}"
}
},
"response": [
{
"id": "103e959b-3d59-4a3b-9a0f-eef9206733e9",
"name": "An array of profiles",
"originalRequest": {
"url": {
"path": [
"inventory",
":searchString"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "skip",
"value": "<integer>"
}
],
"variable": [
{
"type": "any",
"key": "searchString"
}
]
},
"header": [
{
"description": "maximum number of records to return",
"key": "limit",
"value": "<integer>"
}
],
"method": "POST",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"description": "The date.",
"key": "x-date",
"value": "2012-06-15"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"id\": \"urn:uuid:986f1de0-b002-2c4e-63a7-724ac665365b\",\n \"name\": \"ioneyed\",\n \"given_name\": \"Robert\",\n \"family_name\": \"Buchanan\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
},
{
"id": "7e2062e0-d928-4ae5-924b-858d3bcce494",
"name": "The user is unauthorized for this action",
"originalRequest": {
"url": {
"path": [
"inventory",
":searchString"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "skip",
"value": "<integer>"
}
],
"variable": [
{
"type": "any",
"key": "searchString"
}
]
},
"header": [
{
"description": "maximum number of records to return",
"key": "limit",
"value": "<integer>"
}
],
"method": "POST",
"body": {}
},
"status": "Unauthorized",
"code": 401,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": \"PROFILE-108-401\",\n \"message\": \"you do not have appropriate credentials\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
},
{
"id": "9a089428-7a6c-4b30-ba0c-b036383af51e",
"name": "/inventory/:searchString",
"request": {
"name": "/inventory/:searchString",
"description": {},
"url": {
"path": [
"inventory",
":searchString"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"disabled": false,
"type": "any",
"value": "sed eu",
"key": "searchString",
"description": "pass an optional search string for looking up inventory"
}
]
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "PUT",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"dolore ex consequat\",\n \"alternateName\": \"id consequat Ut\",\n \"providerId\": \"Ut reprehenderit aute ea consectetur\"\n}",
"options": {
"raw": {
"language": "json"
}
}
}
},
"response": [
{
"id": "2b4dd71c-4664-4685-8c7c-8ef5bf8f6704",
"name": "successful operation",
"originalRequest": {
"url": {
"path": [
"inventory",
":searchString"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"disabled": false,
"type": "any",
"value": "sed eu",
"key": "searchString",
"description": "pass an optional search string for looking up inventory"
}
]
},
"method": "PUT",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "\"sed eu\"",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "https://example.com"
}
],
"info": {
"_postman_id": "758b4b2c-df93-4250-a287-6e526f194a75",
"name": "Simple Inventory API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "This is a simple API\n\nContact Support:\n Email: you@your-company.com",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,248 @@
openapi: 3.1.0
servers:
- description: Internal $refs
url: https://example.com
info:
description: This is a simple API
version: "1.0.0"
title: Simple Inventory API
contact:
email: you@your-company.com
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/inventory/{searchString}:
parameters:
- $ref: '#/components/parameters/searchString'
post:
summary: searches inventory
operationId: searchInventory
description: |
By passing in the appropriate options, you can search for
available inventory in the system
parameters:
- $ref: '#/components/parameters/skip'
- $ref: '#/components/parameters/limit'
requestBody:
$ref: '#/components/requestBodies/inventoryBody'
responses:
'200':
description: 'An array of profiles'
content:
application/json:
schema:
$ref: '#/components/schemas/Profile'
headers:
x-date:
$ref: '#/components/headers/x-date'
'401':
$ref: '#/components/responses/Unauthorized'
put:
requestBody:
$ref: '#/components/requestBodies/ProviderConfig'
responses:
"200":
description: successful operation
content:
application/json:
schema:
type:
- string
components:
headers:
x-date:
description: The date.
schema:
type:
- string
format: date
parameters:
limit:
in: header
name: limit
description: maximum number of records to return
schema:
type:
- integer
format: int32
minimum: 0
maximum: 50
searchString:
in: path
name: searchString
description: pass an optional search string for looking up inventory
required: false
schema:
$ref: '#/components/schemas/SearchString'
skip:
in: query
name: skip
description: number of records to skip for pagination
schema:
type:
- integer
format: int32
minimum: 0
requestBodies:
inventoryBody:
content:
application/json:
schema:
$ref: '#/components/schemas/InventoryItem'
description: Inventory item to add
ProviderConfig:
content:
application/json:
schema:
$ref: '#/components/schemas/ProviderConfig'
responses:
UnexpectedError:
description: An unexpected error has occured
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: 'PROFILE-107-500'
message: 'fixing problems'
Unauthorized:
description: The user is unauthorized for this action
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: 'PROFILE-108-401'
message: 'you do not have appropriate credentials'
Forbidden:
description: The user in forbidden from completing that action
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: 'PROFILE-109-403'
message: 'thou shall not pass for you are forbidden'
NotFound:
description: The resource was not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: 'PROFILE-110-404'
message: 'resource was not found'
schemas:
SearchString:
type:
- string
InventoryItem:
type:
- object
required:
- id
- name
- manufacturer
- releaseDate
properties:
id:
type:
- string
format: uuid
examples:
- d290f1ee-6c54-4b01-90e6-d701748f0851
name:
type:
- string
examples:
- Widget Adapter
releaseDate:
type:
- string
format: date-time
examples:
- '2016-08-29T09:12:33.001Z'
manufacturer:
$ref: '#/components/schemas/Manufacturer'
Manufacturer:
required:
- name
properties:
name:
type:
- string
examples:
- ACME Corporation
homePage:
type:
- string
format: url
examples:
- 'https://www.acme-corp.com'
phone:
type:
- string
examples:
- 408-867-5309
type:
- object
Profile:
type:
- object
required:
- id
- name
- given_name
- family_name
properties:
id:
type:
- string
format: uuid
name:
type:
- string
examples:
- "ioneyed"
given_name:
type:
- string
examples:
- "Robert"
family_name:
type:
- string
examples:
- "Buchanan"
Error:
type:
- object
required:
- code
- message
properties:
code:
type:
- string
pattern: 'PROFILE-\d{3}-\d{3}'
examples:
- "PROFILE-100-507"
message:
type:
- string
examples:
- "we have run out of storage; this is embarrassing, and someone have been paged"
ProviderConfig:
type:
- object
properties:
name:
type:
- string
alternateName:
type:
- string
providerId:
type:
- string

View File

@@ -0,0 +1,165 @@
{
"item": [
{
"id": "98f1665c-b4ee-43d1-8454-51e4b1bc0c1f",
"name": "/api/path_with_multiple_pathvars/:pathvar1/:pathvar2/:pathvar3",
"request": {
"name": "/api/path_with_multiple_pathvars/:pathvar1/:pathvar2/:pathvar3",
"description": {},
"url": {
"path": [
"api",
"path_with_multiple_pathvars",
":pathvar1",
":pathvar2",
":pathvar3"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"description": "(Required) ",
"type": "any",
"value": "66.42473585353362",
"key": "pathvar1"
},
{
"description": "(Required) ",
"type": "any",
"value": "10.018941650763242",
"key": "pathvar2"
},
{
"description": "(Required) ",
"type": "any",
"value": "false",
"key": "pathvar3"
}
]
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "659f472d-f227-4122-a8da-64079749fea4",
"name": "Success",
"originalRequest": {
"url": {
"path": [
"api",
"path_with_multiple_pathvars",
":pathvar1",
":pathvar2",
":pathvar3"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"type": "any",
"key": "pathvar1"
},
{
"type": "any",
"key": "pathvar2"
},
{
"type": "any",
"key": "pathvar3"
}
]
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
},
{
"id": "82704c56-aadb-4925-a6bf-db07b4a8f538",
"name": "/pets",
"request": {
"name": "/pets",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "9a9c0108-1ec7-4ba3-82f2-0c335e650c49",
"name": "Success",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "/"
}
],
"info": {
"_postman_id": "1df2ca7f-6b37-48ce-b340-8367b28a59ee",
"name": "Incorrect validation of Path var",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,71 @@
{
"openapi": "3.1.0",
"info": {
"title": "Incorrect validation of Path var",
"version": "v1"
},
"paths": {
"/api/path_with_multiple_pathvars/{pathvar1}/{pathvar2}/{pathvar3}": {
"get": {
"parameters": [
{
"name": "pathvar1",
"in": "path",
"required": true,
"schema": {
"maximum": 70,
"minimum": 10,
"type": ["number"],
"format": "double"
}
},
{
"name": "pathvar2",
"in": "path",
"required": true,
"schema": {
"maximum": 20,
"minimum": 0,
"type": ["number"],
"format": "double"
}
},
{
"name": "pathvar3",
"in": "path",
"required": true,
"schema": {
"type": ["boolean"]
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/{petId}": {
"get": {
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"schema": {
"type": ["number"],
"format": "double"
},
"example": 99.99
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
}
}
}

View File

@@ -0,0 +1,136 @@
{
"item": [
{
"id": "a2b99009-5e11-43ac-b411-fa7fd1425262",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "099ccc06-611e-4e31-8462-7e66ba7783e7",
"name": "List all pets",
"request": {
"name": "List all pets",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"disabled": false,
"key": "limit",
"value": "prop2,32,prop1,[object Object]",
"description": "(Required) How many items to return at one time (max 100)"
}
],
"variable": []
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "24e8f452-28f2-44a2-839e-081e2d54c287",
"name": "An paged array of pets",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "prop2,32,prop1,[object Object]"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"disabled": false,
"description": "A link to the next page of responses",
"key": "x-next",
"value": "nostrud do"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "[\n {\n \"id\": 17889649,\n \"name\": \"enim tempor minim\",\n \"tag\": \"incididunt esse nostrud culpa sit\"\n },\n {\n \"id\": 54275385,\n \"name\": \"et labore veniam\",\n \"tag\": \"elit ut si\"\n }\n]",
"cookie": [],
"_postman_previewlanguage": "json"
},
{
"id": "5b174b95-db8c-4a53-9a89-a817b47e9d1b",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "prop2,32,prop1,[object Object]"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": -28330006,\n \"message\": \"qui occaecat magna\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"type": "string",
"value": "http://petstore.swagger.io/v1",
"key": "baseUrl"
}
],
"info": {
"_postman_id": "0861b241-23ad-435c-a80e-af77f30b2acd",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,92 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: true
explode: false
schema:
type:
- object
required:
- prop2
properties:
prop1:
type:
- object
properties:
prop1_1:
type:
- string
prop2:
type:
- integer
example:
- 32
responses:
'200':
description: An paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type:
- string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string
Pets:
type:
- array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type:
- integer
format: int32
message:
type:
- string

View File

@@ -0,0 +1,90 @@
{
"item": [
{
"id": "69d7005c-6a60-4a30-b71f-7d88f9341898",
"name": "Demo invalid type",
"request": {
"name": "Demo invalid type",
"description": {},
"url": {
"path": [
"api"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "false"
}
},
"response": [
{
"id": "c457a34e-3b7d-4052-a034-3a2fe1cf7e24",
"originalRequest": {
"url": {
"path": [
"api"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "",
"value": null
}
],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "true"
}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "123",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "/"
}
],
"info": {
"_postman_id": "f12b0220-20c0-4619-bfae-7b8d7c7574cf",
"name": "Demo API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,24 @@
openapi: 3.1.0
info:
version: 1.0
title: Demo API
paths:
/api:
post:
summary: 'Demo invalid type'
requestBody:
description: 'Cannot use type boolean'
content:
application/json:
schema:
type:
- boolean
responses:
'200':
content:
application/json:
schema:
type:
- integer
minimum: 5
maximum: 10

View File

@@ -0,0 +1,160 @@
{
"item": [
{
"id": "9861bc73-aafe-4c44-8c91-f42e4d820ae6",
"name": "pet",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "23d37c51-7a63-412e-b15a-10c336d49615",
"name": "Updates a pet in the store with form data",
"request": {
"name": "Updates a pet in the store with form data",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"disabled": false,
"key": "user[id]",
"value": "notAnInteger",
"description": "(Required) info about user"
},
{
"disabled": false,
"key": "user[name]",
"value": "John Johanson",
"description": "(Required) info about user"
},
{
"disabled": false,
"key": "user[address][city]",
"value": "Delhi",
"description": "(Required) info about user"
},
{
"disabled": false,
"key": "propArrayComplex[0][prop1ArrayComp]",
"value": "notAnInteger",
"description": "(Required) deepObject with complex array structure"
},
{
"disabled": false,
"key": "propArrayComplex[0][prop2ArrayComp]",
"value": "qui anim",
"description": "(Required) deepObject with complex array structure"
},
{
"disabled": false,
"key": "propArrayComplex[1][prop1ArrayComp]",
"value": "87313126",
"description": "(Required) deepObject with complex array structure"
},
{
"disabled": false,
"key": "propArrayComplex[1][prop2ArrayComp]",
"value": "reprehenderit",
"description": "(Required) deepObject with complex array structure"
}
],
"variable": []
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "76137f7a-7d78-4f8b-837f-d678124c0b8e",
"name": "Pet updated.",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "user[id]",
"value": "123"
},
{
"key": "user[name]",
"value": "John Johanson"
},
{
"key": "user[address][city]",
"value": "Delhi"
},
{
"key": "user[address][country]",
"value": "India"
},
{
"key": "propArrayComplex[0][prop1ArrayComp]",
"value": "70013937"
},
{
"key": "propArrayComplex[0][prop2ArrayComp]",
"value": "pariatur sit consectetur minim"
},
{
"key": "propArrayComplex[1][prop1ArrayComp]",
"value": "-77852940"
},
{
"key": "propArrayComplex[1][prop2ArrayComp]",
"value": "amet"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"type": "string",
"value": "http://petstore.swagger.io/v1",
"key": "baseUrl"
}
],
"info": {
"_postman_id": "c3eff23a-fbd9-40b7-9029-7e9699d9bb1b",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,70 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
tags:
- pet
summary: Updates a pet in the store with form data
operationId: updatePetWithForm
parameters:
- name: user
in: query
description: info about user
required: true
style: deepObject
schema:
type:
- object
properties:
id:
type:
- integer
examples:
- 123
name:
type:
- string
examples:
- John Johanson
address:
type:
- object
properties:
city:
type:
- string
examples:
- Delhi
country:
type:
- string
examples:
- India
- name: propArrayComplex
in: query
description: deepObject with complex array structure
required: true
style: deepObject
schema:
type:
- array
items:
type:
- object
properties:
prop1ArrayComp:
type:
- integer
prop2ArrayComp:
type:
- string
responses:
'200':
description: Pet updated.

View File

@@ -0,0 +1,145 @@
{
"item": [
{
"id": "6a23e0c5-f874-4d64-917f-436e8b6630b7",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "58a1eaab-6150-4bd8-9606-aae2a519d1dc",
"name": "Create a pet",
"request": {
"name": "Create a pet",
"description": {},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"description": "",
"key": "limit",
"value": "-74270672"
}
],
"variable": []
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"id\": -97299140,\n \"name\": \"dolore\",\n \"tag\": \"nostrud et in\"\n}"
}
},
"response": [
{
"id": "497bb8cc-bf09-4712-b3c2-38a7f7772e00",
"name": "Null response",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "<integer>"
}
],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"id\": -97299140,\n \"name\": \"dolore\",\n \"tag\": \"nostrud et in\"\n}"
}
},
"status": "Created",
"code": 201,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
},
{
"id": "51d2030f-e874-4b29-b8b7-a92de6566ec0",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "<integer>"
}
],
"variable": []
},
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"id\": -97299140,\n \"name\": \"dolore\",\n \"tag\": \"nostrud et in\"\n}"
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": 94595733,\n \"message\": \"Duis sit qui\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "9836d256-0ada-42d6-a825-a103d0bb3695",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,71 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
post:
summary: Create a pet
operationId: createPets
tags:
- pets
parameters:
- name: limit
in: query
required: false
schema:
type:
- integer
format: int32
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type:
- object
minProperties: 4
required:
- id
- name
properties:
id:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string
Error:
type:
- object
required:
- code
- message
properties:
code:
type:
- integer
format: int32
message:
type:
- string

View File

@@ -0,0 +1,201 @@
{
"item": [
{
"id": "f5983708-1a61-43a4-919b-ca40a34fe2a3",
"name": "pet",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "9c4d4bf3-c8f6-47f5-83d6-6e25f89c1314",
"name": "Updates a pet in the store with form data",
"request": {
"name": "Updates a pet in the store with form data",
"description": {},
"url": {
"path": [
"pets",
":petId"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"description": "(Required) ID of pet that needs to be updated",
"type": "any",
"value": "elit nulla",
"key": "petId"
}
]
},
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "prop1",
"value": "hello"
},
{
"key": "prop2",
"value": "false"
},
{
"key": "propObjectNonExplodable",
"value": "prop3,hello,prop4,true"
},
{
"key": "propArray",
"value": "str1"
},
{
"key": "propArray",
"value": "999"
},
{
"key": "propSimple",
"value": "123"
},
{
"disabled": false,
"key": "propDeepObject[id]",
"value": "123"
},
{
"disabled": false,
"key": "propDeepObject[name]",
"value": "John Johanson"
},
{
"disabled": false,
"key": "propDeepObject[address][city]",
"value": "123"
},
{
"disabled": false,
"key": "propDeepObject[address][country]",
"value": "India"
},
{
"disabled": false,
"key": "propArrayComplex[0][prop1ArrayComp]",
"value": "notAnInteger"
},
{
"disabled": false,
"key": "propArrayComplex[0][prop2ArrayComp]",
"value": "irure labore Lorem consequat l"
},
{
"disabled": false,
"key": "propArrayComplex[1][prop1ArrayComp]",
"value": "-14216671"
},
{
"disabled": false,
"key": "propArrayComplex[1][prop2ArrayComp]",
"value": "officia"
}
]
}
},
"response": [
{
"id": "613fc0d2-9836-48a6-9518-8f239ba9427f",
"name": "Pet updated.",
"originalRequest": {
"url": {
"path": [
"pets",
":petId"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"type": "any",
"key": "petId"
}
]
},
"method": "POST",
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "prop1",
"value": "hello"
},
{
"key": "prop2",
"value": "world"
},
{
"key": "propObjectNonExplodable",
"value": "prop1,hello,prop2,world"
},
{
"key": "propArray",
"value": "str1"
},
{
"key": "propArray",
"value": "str2"
},
{
"key": "propSimple",
"value": "123"
}
]
}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "acd16ff0-eda5-48b4-b0de-4d35138da21d",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,137 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets/{petId}:
post:
tags:
- pet
summary: Updates a pet in the store with form data
operationId: updatePetWithForm
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
schema:
type:
- string
requestBody:
content:
'application/x-www-form-urlencoded':
schema:
properties:
propObjectExplodable:
type:
- object
properties:
prop1:
type:
- string
examples:
- hello
prop2:
type:
- string
examples:
- world
propObjectNonExplodable:
type:
- object
properties:
prop3:
type:
- string
examples:
- hello
prop4:
type:
- string
examples:
- world
propArray:
type:
- array
items:
type:
- string
examples:
- exampleString
examples:
- - str1
- str2
propSimple:
type:
- integer
examples:
- 123
propDeepObject:
type:
- object
properties:
id:
type:
- integer
examples:
- 123
name:
type:
- string
examples:
- John Johanson
address:
type:
- object
properties:
city:
type:
- string
examples:
- Delhi
country:
type:
- string
examples:
- India
propArrayComplex:
type:
- array
items:
type:
- object
properties:
prop1ArrayComp:
type:
- integer
prop2ArrayComp:
type:
- string
propMissingInReq:
type:
- integer
description: This property is not available in matched collection.
examples:
- 321
required:
- propMissingInReq
encoding:
propObjectExplodable:
style: form
explode: true
propObjectNonExplodable:
style: form
explode: false
propDeepObject:
style: deepObject
explode: true
propArrayComplex:
style: deepObject
explode: true
responses:
'200':
description: Pet updated.

View File

@@ -0,0 +1,85 @@
{
"info": {
"_postman_id": "7a1d1b7f-f6c3-4ce1-8c1f-1e93fc4a470d",
"name": "lets see",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"id": "req",
"name": "Sample endpoint: Returns details about a particular user",
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/user?id=1",
"host": [
"{{baseUrl}}"
],
"path": [
"user"
],
"query": [
{
"key": "id",
"value": "1",
"description": "(Required) ID of the user"
}
]
},
"body": {
"mode": "raw",
"raw": "{\n \"data\": [\n {\n \"entityId\": \"5e5792b234d88e12b8511b92\",\n \"accountNumber\": \"1YNykgIi3T2NDeElON0IqcPOpPI\",\n \"entityName\": \"Farmer Freddy's Veg\",\n \"entityPhone\": \"+4420832132132\",\n \"incType\": \"sole\",\n \"companyNumber\": 10000,\n \"needThisNot\": \"hello\",\n \"website\": \"https://farmer-freddy.null\",\n \"turnover\": 10000,\n \"description\": \"def\",\n \"status\": \"tradingAccepted\",\n \"wants\": [\n \"carpentry\",\n \"beer\",\n \"beer\"\n ],\n \"isFavorite\": true\n }\n ],\n \"meta\": {\n \"notNeeded\": 1,\n \"numberOfResults\": 1,\n \"totalPages\": 1\n }\n}"
}
},
"response": [
{
"id": "res",
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/user?id=1",
"host": [
"{{baseUrl}}"
],
"path": [
"user"
],
"query": [
{
"key": "id",
"value": "1"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [],
"cookie": [],
"body": "{\n \"data\": [\n {\n \"entityId\": \"5e5792b234d88e12b8511b92\",\n \"accountNumber\": \"1YNykgIi3T2NDeElON0IqcPOpPI\",\n \"entityName\": \"Farmer Freddy's Veg\",\n \"entityPhone\": \"+4420832132132\",\n \"incType\": \"sole\",\n \"companyNumber\": \"none\",\n \"website\": \"https://farmer-freddy.null\",\n \"turnover\": 10000,\n \"description\": \"High quality carpentry at a reasonable price.\",\n \"status\": \"wrongEnum\",\n \"offers\": [\n \"organic-vegetables\",\n \"organic-fruits\"\n ],\n \"wants\": [\n \"carpentry\",\n \"beer\"\n ],\n \"isFavorite\": true\n }\n ],\n \"meta\": {\n \"numberOfResults\": 1,\n \"totalPages\": 1\n }\n}"
}
]
}
],
"variable": [
{
"id": "baseUrl",
"key": "baseUrl",
"value": "http://localhost:3000",
"type": "string"
}
],
"protocolProfileBehavior": {}
}

View File

@@ -0,0 +1,121 @@
openapi: 3.1.0
info:
version: 1
title: IMPORT-202
servers:
- url: 'http://localhost:3000'
paths:
/user:
post:
summary: 'Sample endpoint: Returns details about a particular user'
operationId: listUser
tags:
- user
parameters:
- name: id
in: query
description: ID of the user
required: true
schema:
type:
- integer
format: int32
requestBody:
content:
application/json:
schema:
type:
- object
properties:
data:
type:
- array
items:
$ref: '#/components/schemas/Entity'
meta:
type:
- object
maxProperties: 1
additionalProperties: false
properties:
numberOfResults:
type:
- number
format: int32
totalPages:
type:
- number
format: int32
responses:
200:
description: OK
components:
schemas:
Entity:
type:
- object
title: Entity
description: A single and unique entity linked to a user
minProperties: 50
required: [entityId, needThis]
dependencies:
id: [needThis, accountNumber]
properties:
entityId:
type:
- string
maxLength: 5
accountNumber:
type:
- string
minLength: 50
entityName:
type:
- string
format: ipv4
entityPhone:
type:
- string
incType:
type:
- string
enum: ['Postman']
companyNumber:
type:
- number
exclusiveMinimum: 10000
website:
type:
- number
turnover:
type:
- integer
format: int32
multipleOf: 7
description:
type:
- string
pattern: '[abc]+'
status:
type:
- string
enum:
- pending
- accepted
- rejected
- tradingPending
- tradingAccepted
- tradingRejected
wants:
type:
- array
uniqueItems: true
items:
type:
- string
isFavorite:
type:
- boolean
needThis:
type:
- string

View File

@@ -0,0 +1,134 @@
{
"item": [
{
"id": "e3b75312-ce49-45b5-987f-03af612be2eb",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "8145304c-1a14-4332-97c6-02f5b536c79b",
"name": "Info for a specific pet",
"request": {
"name": "Info for a specific pet",
"description": {},
"url": {
"path": [
"pets",
":samplePathVar"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"description": "(Required) The id of the pet to retrieve",
"key": "sampleQueryParam",
"value": "{{sampleQueryParamCollectionVar}}"
}
],
"variable": [
{
"description": "(Required) The id of the pet to retrieve",
"type": "any",
"value": "{{petIdCollectionVar}}",
"key": "samplePathVar"
}
]
},
"header": [
{
"description": "(Required) The id of the pet to retrieve",
"key": "sampleHeader",
"value": "{{sampleHeaderCollectionVar}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"petId\": \"{{petIdVar}}\",\n \"name\": \"{{nameVar}}\",\n \"tag\": \"{{tagVar}}\"\n}"
}
},
"response": [
{
"id": "483c6f74-c8aa-41d3-986f-407195d9ea5d",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets",
":samplePathVar"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "sampleQueryParam",
"value": "{{sampleQueryParamCollectionVar}}"
}
],
"variable": [
{
"type": "any",
"key": "samplePathVar"
}
]
},
"header": [
{
"description": "(Required) The id of the pet to retrieve",
"key": "sampleHeader",
"value": "{{sampleHeaderCollectionVar}}"
}
],
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"petId\": \"{{petIdVar}}\",\n \"name\": \"{{nameVar}}\",\n \"tag\": \"{{tagVar}}\"\n}"
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": \"{{codeVar}}\",\n \"message\": \"{{messageVar}}\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "2bba452f-eac2-43bf-b5b5-b813cfa76e43",
"name": "Ignore unresolved pm variables",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,86 @@
openapi: "3.1.0"
info:
version: 1.0.0
title:
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets/{samplePathVar}:
post:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: samplePathVar
in: path
required: true
description: The id of the pet to retrieve
schema:
type:
- integer
example: '{{petIdCollectionVar}}'
- name: sampleQueryParam
in: query
required: true
description: The id of the pet to retrieve
schema:
type:
- number
example: '{{sampleQueryParamCollectionVar}}'
- name: sampleHeader
in: header
required: true
description: The id of the pet to retrieve
schema:
type:
- boolean
example: '{{sampleHeaderCollectionVar}}'
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type:
- object
properties:
petId:
type:
- integer
format: int64
name:
type:
- string
tag:
type:
- string
examples:
- petId: '{{petIdVar}}'
name: '{{nameVar}}'
tag: '{{tagVar}}'
Error:
type:
- object
properties:
code:
type:
- integer
format: int32
message:
type:
- string
examples:
- code: '{{codeVar}}'
message: '{{messageVar}}'

View File

@@ -0,0 +1,145 @@
{
"item": [
{
"id": "1e465050-08f3-47a0-8a7e-6fb35546a212",
"name": "/users/admin/:userId",
"request": {
"name": "/users/admin/:userId",
"description": "/users/admin/{userId}",
"url": {
"path": [
"users",
"admin",
":userId"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"description": "(Required) ",
"type": "any",
"value": "12345",
"key": "userId"
}
]
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "097e701a-e964-43d9-bb37-ccbe747d3a7b",
"name": "/users/admin/{userId}",
"originalRequest": {
"url": {
"path": [
"users",
"admin",
":userId"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": [
{
"type": "any",
"key": "userId"
}
]
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"id\": 2678975,\n \"name\": \"cillum minim aliqua\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
},
{
"id": "a7645f69-07a1-4d8b-97b4-575fd09c686c",
"name": "/users/admin/profile",
"request": {
"name": "/users/admin/profile",
"description": "/users/admin/profile",
"url": {
"path": [
"users",
"admin",
"profile"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "e485cfd8-b63d-46cd-b305-606d7b900ce1",
"name": "/users/admin/profile",
"originalRequest": {
"url": {
"path": [
"users",
"admin",
"profile"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"id\": 2678975,\n \"name\": \"cillum minim aliqua\"\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "81a0590b-0dfb-4ab8-8b6c-ea8e23b554bc",
"name": "Validation Option tests",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,80 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Validation Option tests
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/users/admin/{userId}:
get:
description: /users/admin/{userId}
parameters:
- name: userId
in: path
required: true
schema:
type:
- string
responses:
'200':
description: /users/admin/{userId}
content:
application/json:
schema:
type:
- object
properties:
id:
type:
- integer
format: int64
name:
type:
- string
/users/admin/profile:
get:
description: /users/admin/{userId}
responses:
'200':
description: /users/admin/profile
content:
application/json:
schema:
type:
- object
properties:
id:
type:
- integer
format: int64
name:
type:
- string
/admin/{adminId}:
get:
description: /admin/{adminId}
parameters:
- name: adminId
in: path
required: true
schema:
type:
- string
responses:
'200':
description: /admin/{adminId}
content:
application/json:
schema:
type:
- object
properties:
id:
type:
- integer
format: int64
name:
type:
- string

View File

@@ -0,0 +1,133 @@
{
"item": [
{
"id": "24c0a942-d439-45ca-84f7-7728b449169c",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "e96f3f5b-f8d3-4548-b514-8fa1e937bbd3",
"name": "Info for a specific pet",
"request": {
"name": "Info for a specific pet",
"description": {},
"url": {
"path": [
"pets",
":petId"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"description": "(Required) ",
"key": "limit",
"value": "Not a Number"
}
],
"variable": [
{
"description": "(Required) The id of the pet to retrieve",
"type": "any",
"value": "Not an Integer",
"key": "petId"
}
]
},
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"method": "POST",
"auth": null,
"body": {
"mode": "raw",
"raw": "{\n \"petId\": 8,\n \"name\": \"My name is less than 30 chars\",\n \"tag\": true,\n \"breeds\": [\"Bulldog\", \"Timberwolf\", \"GrizzlyBear\"]\n}"
}
},
"response": [
{
"id": "eeeb3cf9-e830-4514-a1a0-4af90feda7b1",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets",
":petId"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "Not a Number"
}
],
"variable": [
{
"type": "any",
"key": "petId"
}
]
},
"header": [
{
"description": "(Required) ",
"key": "pet-quantity",
"value": "Not a Boolean"
}
],
"method": "POST",
"body": {
"mode": "raw",
"raw": "{\n \"petId\": 8,\n \"name\": \"My name is less than 30 chars\",\n \"tag\": true,\n \"breeds\": [\"Bulldog\", \"Timberwolf\", \"GrizzlyBear\"]\n}"
}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"description": "The number of allowed requests in the current period",
"key": "X-Rate-Limit-Limit",
"value": "<string>"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"code\": \"{{codeVar}}\",\n \"message\": 123.456\n}",
"cookie": [],
"_postman_previewlanguage": "json"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "648dcfad-2423-4619-a3ad-48ec88de11a9",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,108 @@
openapi: "3.1.0"
info:
version: 1.0.0
title:
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets/{petId}:
post:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type:
- integer
examples:
- 'Not an Integer'
- name: limit
in: query
required: true
schema:
type:
- number
examples:
- 'Not a Number'
- name: pet-quantity
in: header
description: Quantity of pets available
required: true
schema:
type:
- boolean
examples:
- 'Not a Boolean'
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
default:
description: unexpected error
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type:
- integer
examples:
- '<string>'
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type:
- object
required:
- petId
- name
- tag
- breeds
properties:
petId:
type:
- integer
format: int64
name:
type:
- string
minLength: 30
tag:
type:
- string
breeds:
type:
- array
minItems: 3
maxItems: 3
items:
type:
- string
enum: ["Bulldog", "Retriever", "Timberwolf", "Grizzly", "Husky"]
Error:
type:
- object
properties:
code:
type:
- integer
format: int32
multipleOf: 7
message:
type:
- string
examples:
- code: '{{codeVar}}'
message: 123.456

View File

@@ -0,0 +1,149 @@
{
"item": [
{
"id": "4e91e114-35be-4165-b6a2-760921ad7a59",
"name": "pets",
"description": {
"content": "",
"type": "text/plain"
},
"item": [
{
"id": "73046eed-2976-4767-8c58-c7890370d7d7",
"name": "List all pets",
"request": {
"name": "List all pets",
"description": "Wrong description",
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"description": "How many items to return at one time (max 100)",
"key": "limit",
"value": "-99451457"
}
],
"variable": []
},
"method": "GET",
"auth": null
},
"response": [
{
"id": "46e62ee6-8603-419f-938e-d111db7dc8be",
"name": "unexpected error",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [
{
"key": "limit",
"value": "<integer>"
}
],
"variable": []
},
"method": "GET",
"body": {}
},
"status": "Internal Server Error",
"code": 500,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
},
{
"id": "de9fd791-43d2-4251-8e00-8349ee2e2c79",
"name": "Create a pet",
"request": {
"description": {
"content": null,
"type": "text/plain"
},
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "POST",
"auth": null
},
"response": [
{
"id": "1cf53180-3534-4ab2-9f73-34a3176941df",
"name": "Null response",
"originalRequest": {
"url": {
"path": [
"pets"
],
"host": [
"{{baseUrl}}"
],
"query": [],
"variable": []
},
"method": "POST",
"body": {}
},
"status": "Created",
"code": 201,
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"body": "",
"cookie": [],
"_postman_previewlanguage": "text"
}
],
"event": []
}
],
"event": []
}
],
"event": [],
"variable": [
{
"id": "baseUrl",
"type": "string",
"value": "http://petstore.swagger.io/v1"
}
],
"info": {
"_postman_id": "25a51c10-79ed-45fa-a82d-11b4fa79b9b1",
"name": "Swagger Petstore",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"description": {
"content": "",
"type": "text/plain"
}
}
}

View File

@@ -0,0 +1,37 @@
openapi: "3.1.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets Updated
description: Description for GET /pets - List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type:
- integer
format: int32
responses:
default:
description: unexpected error
post:
summary: Create a pet
description: Description for POST /pets - Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
const { getSpecVersion } = require('../../lib/common/versionUtils'),
const { getSpecVersion, filterOptionsByVersion } = require('../../lib/common/versionUtils'),
expect = require('chai').expect;
describe('getSpecVersion', function() {
@@ -170,3 +170,73 @@ describe('getSpecVersion', function() {
expect(specVersion).to.be.equal('2.0');
});
});
describe('filterOptionsByVersion method', function() {
it('Should return the options supported in version 3.1', function() {
const optionsMock = [
{
id: 'optionA',
name: 'option A',
supportedIn: ['3.0'],
default: 'A default value for option A'
},
{
id: 'optionB',
name: 'option B',
supportedIn: ['3.0'],
default: 'A default value for option B'
},
{
id: 'optionC',
name: 'option C',
supportedIn: ['3.1'],
default: 'A default value for option C'
},
{
id: 'optionD',
name: 'option D',
supportedIn: ['3.0', '3.1'],
default: 'A default value for option D'
}
],
optionsFiltered = filterOptionsByVersion(optionsMock, '3.1');
expect(optionsFiltered).to.be.an('array');
expect(optionsFiltered.map((option) => {
return option.id;
})).to.include.members(['optionC', 'optionD']);
});
it('Should return the options supported in version 3.0', function() {
const optionsMock = [
{
id: 'optionA',
name: 'option A',
supportedIn: ['3.0'],
default: 'A default value for option A'
},
{
id: 'optionB',
name: 'option B',
supportedIn: ['3.0'],
default: 'A default value for option B'
},
{
id: 'optionC',
name: 'option C',
supportedIn: ['3.1'],
default: 'A default value for option C'
},
{
id: 'optionD',
name: 'option D',
supportedIn: ['3.0', '3.1'],
default: 'A default value for option D'
}
],
optionsFiltered = filterOptionsByVersion(optionsMock, '3.0');
expect(optionsFiltered).to.be.an('array');
expect(optionsFiltered.map((option) => {
return option.id;
})).to.include.members(['optionA', 'optionB', 'optionD']);
});
});

View File

@@ -4,6 +4,7 @@ const SchemaPack = require('../..').SchemaPack,
path = require('path'),
OPENAPI_31_FOLDER = '../data/valid_openapi31X',
OPENAPI_31_COLLECTIONS = '../data/31CollectionTransactions',
VALIDATION_DATA_ISSUES_FOLDER_31_PATH = '../data/31CollectionTransactions/issues',
_ = require('lodash');
describe('Testing openapi 3.1 schema pack convert', function() {
it('Should convert from openapi 3.1 spec to postman collection -- multiple refs', function() {
@@ -454,3 +455,146 @@ describe('Openapi 3.1 schemapack mergeAndValidate', function() {
});
});
});
describe('Resolved issues', function() {
const issue133 = path.join(__dirname, VALIDATION_DATA_ISSUES_FOLDER_31_PATH + '/issue#133.json'),
issue160 = path.join(__dirname, VALIDATION_DATA_ISSUES_FOLDER_31_PATH, '/issue#160.json'),
issue150 = path.join(__dirname, VALIDATION_DATA_ISSUES_FOLDER_31_PATH + '/issue#150.yml'),
issue173 = path.join(__dirname, VALIDATION_DATA_ISSUES_FOLDER_31_PATH, '/issue#173.yml'),
issue152 = path.join(__dirname, VALIDATION_DATA_ISSUES_FOLDER_31_PATH, '/path-refs-error.yaml'),
issue193 = path.join(__dirname, VALIDATION_DATA_ISSUES_FOLDER_31_PATH, '/issue#193.yml');
it('Should generate collection conforming to schema for and fail if not valid ' +
issue152 + ' - version: 3.1', function(done) {
var openapi = fs.readFileSync(issue152, 'utf8'),
refNotFound = 'reference #/paths/~1pets/get/responses/200/content/application~1json/schema/properties/newprop' +
' not found in the OpenAPI spec',
Converter = new SchemaPack({ type: 'string', data: openapi }, { schemaFaker: true });
Converter.convert((err, conversionResult) => {
expect(err).to.be.null;
expect(conversionResult.result).to.equal(true);
expect(conversionResult.output.length).to.equal(1);
expect(conversionResult.output[0].type).to.equal('collection');
expect(conversionResult.output[0].data).to.have.property('info');
expect(conversionResult.output[0].data).to.have.property('item');
expect(conversionResult.output[0].data.item[0].item[1].response[1].body).to.not.contain(refNotFound);
done();
});
});
it(' Fix for GITHUB#133: Should generate collection with proper Path and Collection variables - version: 3.1',
function(done) {
var openapi = fs.readFileSync(issue133, 'utf8'),
Converter = new SchemaPack(
{ type: 'string', data: openapi },
{ requestParametersResolution: 'Example', schemaFaker: true }
);
Converter.convert((err, conversionResult) => {
expect(err).to.be.null;
expect(conversionResult.result).to.equal(true);
expect(conversionResult.output.length).to.equal(1);
expect(conversionResult.output[0].type).to.equal('collection');
expect(conversionResult.output[0].data).to.have.property('info');
expect(conversionResult.output[0].data).to.have.property('item');
expect(conversionResult.output[0].data).to.have.property('variable');
expect(conversionResult.output[0].data.variable).to.be.an('array');
expect(conversionResult.output[0].data.variable[1].key).to.equal('format');
expect(conversionResult.output[0].data.variable[1].value).to.equal('json');
expect(conversionResult.output[0].data.variable[2].key).to.equal('path');
expect(conversionResult.output[0].data.variable[2].value).to.equal('send-email');
expect(conversionResult.output[0].data.variable[3].key).to.equal('new-path-variable-1');
// serialised value for object { R: 100, G: 200, B: 150 }
expect(conversionResult.output[0].data.variable[3].value).to.equal('R,100,G,200,B,150');
expect(conversionResult.output[0].data.variable[4].key).to.equal('new-path-variable-2');
// serialised value for array ["exampleString", "exampleString"]
expect(conversionResult.output[0].data.variable[4].value).to.equal('exampleString,exampleString');
done();
});
});
it('#GITHUB-160 should generate correct display url for path containing servers' +
issue160 + ' - version: 3.1', function(done) {
var openapi = fs.readFileSync(issue160, 'utf8'),
Converter = new SchemaPack({ type: 'string', data: openapi }, {});
Converter.convert((err, conversionResult) => {
expect(err).to.be.null;
expect(conversionResult.result).to.equal(true);
expect(conversionResult.output.length).to.equal(1);
expect(conversionResult.output[0].type).to.equal('collection');
expect(conversionResult.output[0].data).to.have.property('info');
expect(conversionResult.output[0].data).to.have.property('item');
expect(conversionResult.output[0].data.item[0].item[0].request.url.host[0]).to.equal('{{pets-Url}}');
done();
});
});
it('[Github #173] - should add headers correctly to sample request in examples(responses) - ' +
'version: 3.1', function (done) {
var openapi = fs.readFileSync(issue173, 'utf8'),
Converter = new SchemaPack({ type: 'string', data: openapi }, {});
Converter.convert((err, conversionResult) => {
let responseArray;
expect(err).to.be.null;
responseArray = conversionResult.output[0].data.item[0].response;
expect(responseArray).to.be.an('array');
responseArray.forEach((response) => {
let headerArray = response.originalRequest.header;
expect(headerArray).to.be.an('array').that.is.not.empty;
expect(headerArray).to.eql([
{
key: 'access_token',
value: 'X-access-token',
description: 'Access token',
disabled: false
}
]);
});
done();
});
});
it('[Github #193] - should handle minItems and maxItems props for (type: array) appropriately - ' +
'version: 3.1', function (done) {
var openapi = fs.readFileSync(issue193, 'utf8'),
Converter = new SchemaPack({ type: 'string', data: openapi }, {});
Converter.convert((err, conversionResult) => {
let responseBody;
expect(err).to.be.null;
responseBody = JSON.parse(conversionResult.output[0].data.item[0].response[0].body);
expect(responseBody).to.be.an('object');
expect(responseBody).to.have.keys(['min', 'max', 'minmax', 'nomin', 'nomax', 'nominmax']);
// Check for all cases (number of items generated are kept as valid and minimum as possible)
// maxItems # of items when minItems not defined (and maxItems < 2)
expect(responseBody.min).to.have.length(1);
// limit(20) # of items when minItems > 20
expect(responseBody.max).to.have.length(20);
// minItems # of items when minItems and maxItems both is defined
expect(responseBody.minmax).to.have.length(3);
// default # of items when minItems not defined (and maxItems >= 2)
expect(responseBody.nomin).to.have.length(2);
// minItems # of items when maxItems not defined
expect(responseBody.nomax).to.have.length(4);
// default # of items when minItems and maxItems not defined
expect(responseBody.nominmax).to.have.length(2);
done();
});
});
it('[GitHub #150] - should generate collection if examples are empty - ' +
'version: 3.1', function (done) {
var openapi = fs.readFileSync(issue150, 'utf8'),
Converter = new SchemaPack({ type: 'string', data: openapi }, { schemaFaker: false });
Converter.convert((err, conversionResult) => {
expect(err).to.be.null;
expect(conversionResult.result).to.equal(true);
expect(conversionResult.output.length).to.equal(1);
expect(conversionResult.output[0].type).to.equal('collection');
expect(conversionResult.output[0].data).to.have.property('info');
expect(conversionResult.output[0].data).to.have.property('item');
done();
});
});
});