mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
WIP: added check for checking readOnly properties in the response object
This commit is contained in:
13
lib/util.js
13
lib/util.js
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user