WIP: added check for checking readOnly properties in the response object

This commit is contained in:
Dhroov Gupta
2019-08-08 12:08:53 +05:30
parent f3983fe380
commit a4fda666d2
3 changed files with 107 additions and 23 deletions

View File

@@ -19,6 +19,10 @@ const sdk = require('postman-collection'),
TEXT_PLAIN = 'text/plain',
TEXT_HTML = 'text/html',
FORM_DATA = 'multipart/form-data',
REQUEST_TYPE = {
GET: 'GET',
POST: 'POST'
},
authMap = {
basicAuth: 'basic',
bearerAuth: 'bearer',
@@ -1156,6 +1160,15 @@ module.exports = {
}
});
if (originalRequest.method === REQUEST_TYPE.GET) {
let resultingSchemaProperties;
for (let cTypeHeader in response.content) {
console.log(cTypeHeader,'here')
let schemaProperties = response.content[cTypeHeader]
console.log(schemaProperties,'schema properties')
}
}
responseBodyWrapper = this.convertToPmResponseBody(response.content);
if (responseBodyWrapper.contentTypeHeader) {

View File

@@ -5,12 +5,7 @@
"title": "Swagger Petstore",
"license": {
"name": "MIT"
},
"contact": {
"name": "API Support",
"url": "http://www.example.com/support",
"email": "support@example.com"
}
}
},
"servers": [
{
@@ -18,32 +13,70 @@
}
],
"paths": {
"/pets": {
"post": {
"/pets/{petId}": {
"get": {
"summary": "Info for a specific pet",
"operationId": "showPetById",
"tags": [
"pets"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "integer",
"format": "int32"
}
}
}
},
],
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"description": "The id of the pet to retrieve",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"content": {
"application/json": {
"schema": {
"type": "integer",
"format": "int32",
"readOnly": "true"
"$ref": "#/components/schemas/Pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"summary": "Create a pet",
"operationId": "createPets",
"tags": [
"pets"
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
@@ -51,5 +84,43 @@
}
}
}
},
"components": {
"schemas": {
"Pet": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"readOnly": "true"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}

View File

@@ -51,7 +51,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
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');
console.log(conversionResult.output[0].data.item[0], 'conversion result');
// console.log(conversionResult.output[0].data.item[0], 'conversion result');
done();
});
});