Coder Social home page Coder Social logo

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

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swagger2-postman2's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Import OpenApi: issue with multiple "_" in host variable

Describe the bug
When importing a json openapi spec with multiple "_" in a variable name as "host", the generated urls are wrong.

To Reproduce
Steps to reproduce the behavior:

  1. Use PetStore openapi spec
  2. Change "host": "petstore.swagger.io", to "host":"{{petstore_url_port}}",
  3. Import spec in postman
  4. See that generated url are https://{{petstore_url_portpostman_variable_close/_DB/v2/pet

Expected behavior
Generated url are https://{{petstore_url_port}}/v2/pet

App information (please complete the following information):

  • App Type: Native App
  • Postman Version: 7.0.9
  • OS: Win 10

Additional context
Using a variable name with a single "_", eg "{{petstore_url}}" works as expected

When is the next scheduled release?

Great job on this library!

ed10a90 fixes 2 issues:

  1. When a tree node has requestCount = 1 but no requests (child node has it).
  2. Having a fallback when json-schema-faker is unable to handle a format.

I’d like to use this fix but cannot pull from GitHub - need it to be in NPM registry.
Any chance you could release a new version soon?

Body params descriptions are not used

Hi,

is it intentional that the descriptions of body parameters are not used in the Postman collection after the conversion?

From your README.md:

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.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Could not import Open API spec v2.0

Describe the bug
This OAS v2.0 will not import into Postman v7.2.2 (either from a file or from a link). However the import previously worked on Postman v6.7.4.

To Reproduce
Steps to reproduce the behavior:

Importing as link

  1. Import this OAS v2.0 link: https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.15/api/openapi-spec/swagger.json
  2. See error: Swagger 2.0: Could not import

Importing as file

  1. Download and save as a file, and then import this OAS v2.0 file: https://github.com/kubernetes/kubernetes/blob/release-1.15/api/openapi-spec/swagger.json
  2. See error: Swagger 2.0: Could not import

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2019-07-01 at 4 54 56 PM

App information (please complete the following information):
macOS v7.2.2

Long routes lead to lots of extra folders

An optional tree collapse can lighten the unnecessary hierarchy.

Routes at:
/organization/_apis/one
/organization/_apis/one/two/three
/organization/_apis/one/two/three/four

Currently

  • /organization
    • _apis
      • one
        • two
          • three
            • four

Collapsed

  • /organization/../one
    • two/three
      • four

I have a commit in a fork I'll link later as an option.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

gitignore will be not respected

The gitignore file was added, but the files/folder were not deleted from the repo.
node_modules and .vscode folder need to be removed

Cant't found types to use it with typescript

I am using typescript and install swagger2-postman2, but when I import it i got the error

Could not find a declaration file for module 'swagger2-postman2'. 'node_modules/swagger2-postman2/index.js' implicitly has an 'any' type.
  Try `npm install @types/swagger2-postman2` if it exists or add a new declaration (.d.ts) file containing `declare module 'swagger2-postman2';`ts(7016)

If i try npm install @types/swagger2-postman2 the response is no found.

Could you provide .d.ts file with typescript types.

Case sensitive routes cause folder duplication

Routes shouldn't be case sensitive. in helpers.js@getTreeFromPaths we can just index treeNode with the thisPath[I].toUpperCase() to consolidate, it doesn't bleed into the output at the end.

I have a PR in a fork I'll attach later if acceptable as a change.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Cannot read property 'method' of undefined in helpers.js

var validResult = Swagger2Postman.validate(swaggerPayloadJson)
if (validResult) {
  var convertResult = Swagger2Postman.convert(swaggerPayloadJson)
}

Even if the swagger config seems to be "valid", the converter throw an exeption:

TypeError: Cannot read property 'method' of undefined
at Object.convertSwaggerRequestToItem (C:\Users\Redeyes\Desktop\swagger-converter\swagger2-postman2-master\lib\helpers.js:158:26)

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.