Coder Social home page Coder Social logo

mikepawlakmsbl / swagger2-postman2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from postmanlabs/swagger2-postman2

0.0 0.0 0.0 8.55 MB

Module and library to convert Swagger 2.0 to a Postman Collection (v2.0)

License: Apache License 2.0

Shell 18.76% JavaScript 81.24%

swagger2-postman2's Introduction

swagger2-Postman

Build Status

Converter for swagger 2.0 JSON to Postman Collection v2 Exports the following functions:

validate(JSON-or-string): Formats like RAML/cURL don't have a JSON representation. For others, JSON is preferred. The result should be an object: {result: true/false, reason: 'string'}. Reason must be populated if the result is false. This function will be used by the app to determine whether or not this converter can be used for the given input.

convert(JSON-or-string): Converts the input to a collection object. Conversion result should be an object: {result: true/false, reason: '', output:[{type: 'collection', data: <object>}] Reason must be populated if the result is false. Collection must be populated if result is true.

Conversion Schema

Postman Swagger2 options examples
collectionName info.title - -
description info.description - -
folderName paths.path - -
requestName method.summary || method.operationId || request.url.raw(in postman) default('operationId') -(requestName) enum[['operationId','summary','url'] -
request.method path.method (all possible http methods) - -
request.headers params (in = header ) - here
request.body params (in = body or formBody) default(true)-(schemaFaker)use json-schema-faker for body conversion here
request.url.raw scheme(http or https) + '://' + host + basePath - -
request.url.params params (in = query) - here
request.url.variables params (in = path) - here
Content-Type header consumes default(true) - add consumes to header -
Accept header produces default(true) - add produces to header -
apikey in (query or header) securityDefinitions(type = apiKey) - -

Header/Query/Path param conversion example

swagger postman
name: api-key
description: session token
in: header
type: integer
default: defaultValue
{
 "key": "api-key",
 "value": defaultValue,
 "description": "session token"
}

Body param conversion example

If in = body

swagger postman
name: role-id
description: role identifier number
in: body
schema: <schemaObject>
"body": {
 "mode": "raw",
 "raw": json-schema-faker(<schemaObject>)
}

If in = formData and consumes = application/x-www-form-urlencoded

swagger postman
name: role-id
description: role identifier number
in: formData
default: defaultValue
"body": {
 "mode": "urlencoded",
 "urlencoded": [{
  "key": "role-id",
  "value": defaultValue,
  "type": "text",
 }]
}

All parmas with above condition are added to urlencoded array.

If in = formData and consumes = multipart/form-data

swagger postman
name: role-id
description: role identifier number
in: formData
default: defaultValue
"body": {
 "mode": "formdata",
 "formdata": [{
  "key": "role-id",
  "value": defaultValue,
  "type": "text",
 }]
}

All parmas with above condition are added to formdata array.

swagger2-postman2's People

Contributors

abhijitpostman avatar abhijitkane avatar vshingala avatar dhroov7 avatar umeshp7 avatar dependabot[bot] avatar shreys7 avatar snyk-bot avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.