All Projects → postmanlabs → Postman Code Generators

postmanlabs / Postman Code Generators

Licence: apache-2.0
Common repository for all code generators shipped with Postman

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Postman Code Generators

Messenger Platform Postman Collection
A delicious Postman collection for all your Messenger Platform needs.
Stars: ✭ 150 (-71.48%)
Mutual labels:  postman, postman-collection
Apiary2postman
Tool for generating a Postman collection from Blueprint API markup or the Apiary API
Stars: ✭ 194 (-63.12%)
Mutual labels:  postman, postman-collection
Postman To K6
Converts Postman collections to k6 script code
Stars: ✭ 180 (-65.78%)
Mutual labels:  postman, postman-collection
Restdocs To Postman
Converts Spring REST Docs cURL snippets to Postman and Insomnia collections
Stars: ✭ 39 (-92.59%)
Mutual labels:  postman, postman-collection
trello-postman-collection
A Postman collection for Trello REST API
Stars: ✭ 20 (-96.2%)
Mutual labels:  postman, postman-collection
Swaggman
OpenAPI Spec SDK and Converter for OpenAPI 3.0 and 2.0 Specs to Postman 2.0 Collections. Example RingCentral spec included.
Stars: ✭ 94 (-82.13%)
Mutual labels:  postman, postman-collection
Api Flow
Universal data structure and converter for API formats (Swagger, RAML, Paw, Postman…)
Stars: ✭ 185 (-64.83%)
Mutual labels:  postman, converter
Azuredevops Postman Collections
The collections allow you to test common Azure DevOps Rest APIs from within Postman.
Stars: ✭ 182 (-65.4%)
Mutual labels:  postman, postman-collection
pmpact
A command line tool to convert Pact files to Postman collections.
Stars: ✭ 15 (-97.15%)
Mutual labels:  postman, postman-collection
graphql-to-postman
Plugin for converting GraphQL to the Postman Collection (v2) format
Stars: ✭ 27 (-94.87%)
Mutual labels:  postman, postman-collection
Pmtoapib
Tool to convert Postman collection exports to Api Blueprint documentation
Stars: ✭ 34 (-93.54%)
Mutual labels:  postman, postman-collection
postman-webex
Postman collections for Webex REST APIs
Stars: ✭ 97 (-81.56%)
Mutual labels:  postman, postman-collection
Newman
Newman is a command-line collection runner for Postman
Stars: ✭ 5,607 (+965.97%)
Mutual labels:  postman, postman-collection
Covid 19 Apis
Postman COVID-19 API Resource Center—API collections to help in the COVID-19 fight.
Stars: ✭ 111 (-78.9%)
Mutual labels:  postman, postman-collection
Gin Boilerplate
The fastest way to deploy a restful api's with Gin Framework with a structured project that defaults to PostgreSQL database and JWT authentication middleware stored in Redis
Stars: ✭ 559 (+6.27%)
Mutual labels:  postman, postman-collection
openman
Postman to OpenAPI Spec converter with mocking and documentation
Stars: ✭ 17 (-96.77%)
Mutual labels:  postman, postman-collection
postman-to-k6
Converts Postman collections to k6 script code
Stars: ✭ 269 (-48.86%)
Mutual labels:  postman, postman-collection
axon
Autogenerate Integration Tests
Stars: ✭ 49 (-90.68%)
Mutual labels:  postman, postman-collection
Bkasciiimage
Convert UIImage to ASCII art
Stars: ✭ 421 (-19.96%)
Mutual labels:  converter
Awesome Openapi3
😎 A list of awesome projects related to OpenAPI 3.0.x, curated by the community
Stars: ✭ 469 (-10.84%)
Mutual labels:  converter


Manage all of your organization's APIs in Postman, with the industry's most complete API development environment.

Supercharge your API workflow.
Modern software is built on APIs. Postman helps you develop APIs faster.

postman-code-generators Build Status

This module converts a Postman SDK Request Object into a code snippet of chosen language.

Every code generator has two identifiers: language and variant.

  • language of a code generator is the programming language in which the code snippet is generated.
  • variant of a code generator is the methodology or the underlying library used by the language to send requests.

List of supported code generators:

Language Variant
C libcurl
C# RestSharp
cURL cURL
Dart http
Go Native
HTTP HTTP
Java OkHttp
Java Unirest
JavaScript Fetch
JavaScript jQuery
JavaScript XHR
NodeJs Axios
NodeJs Native
NodeJs Request
NodeJs Unirest
Objective-C NSURLSession
OCaml Cohttp
PHP cURL
PHP pecl_http
PHP HTTP_Request2
PowerShell RestMethod
Python http.client
Python Requests
Ruby Net:HTTP
Shell Httpie
Shell wget
Swift URLSession

Table of contents

  1. Getting Started
  2. Prerequisite
  3. Usage
    1. Using postman code generators as a Library
  4. Development
    1. Installing Dependencies
    2. Testing
    3. Packaging
  5. Contributing
  6. License

Getting Started

To install postman-code-generators as your dependency

$ npm install postman-code-generators

To get a copy on your local machine

$ git clone https://github.com/postmanlabs/postman-code-generators.git

Prerequisite

To run any of the postman-code-generators, ensure that you have NodeJS >= v8. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager.

Usage

Using postman-code-generators as a Library

There are three functions that are exposed in postman-code-generators: getLanguageList, getOptions, and convert.

getLanguageList

This function returns a list of supported code generators.

Example:
var codegen = require('postman-code-generators'), // require postman-code-generators in your project
    supportedCodegens = codegen.getLanguageList();
    console.log(supportedCodegens);
    // output:
    // [
    //   {
    //     key: 'nodejs',
    //     label: 'NodeJs',
    //     syntax_mode: 'javascript',
    //     variant: [
    //       {
    //         key: 'Requests'
    //       },
    //       {
    //         key: 'Native'
    //       },
    //       {
    //         key: 'Unirest'
    //       }
    //     ]
    //   },
    //   ...
    // ]

getOptions

This function takes in three parameters and returns a callback with error and supported options of that code generator.

  • language - language key from the language list returned from getLanguageList function
  • variant - variant key provided by getLanguageList function
  • callback - callback function with first parameter as error and second parameter as array of options supported by the codegen.

A typical option has the following properties:

  • name - Display name
  • id - unique ID of the option
  • type - Data type of the option. (Allowed data types: boolean, enum, positiveInteger)
  • default - Default value. The value that is used if this option is not specified while creating code snippet
  • description - User friendly description.
Example:
var codegen = require('postman-code-generators'), // require postman-code-generators in your project
    language = 'nodejs',
    variant = 'Request';

    codegen.getOptions(language, variant, function (error, options) {
      if (error) {
        // handle error
      }
      console.log(options);
    });
// output: 
//     [
//     {
//       name: 'Set indentation count',
//       id: 'indentCount',
//       type: 'positiveInteger',
//       default: 2,
//       description: 'Set the number of indentation characters to add per code level'
//     },
//     {
//       name: 'Set indentation type',
//       id: 'indentType',
//       type: 'enum',
//       availableOptions: ['Tab', 'Space'],
//       default: 'Space',
//       description: 'Select the character used to indent lines of code'
//     },
//     ...
//   ];

convert

This function takes in five parameters and returns a callback with error and generated code snippet

  • language - lang key from the language list returned from getLanguageList function
  • variant - variant key provided by getLanguageList function
  • request - Postman-SDK Request Object
  • options - Options that can be used to configure generated code snippet. Defaults will be used for the unspecified attributes
  • callback - callback function with first parameter as error and second parameter as string for code snippet
Example:
var codegen = require('postman-code-generators'), // require postman-code-generators in your project
    sdk = require('postman-collection'), // require postman-collection in your project
    request = new sdk.Request('https://www.google.com'),  //using postman sdk to create request 
    language = 'nodejs',
    variant = 'request',
    options = {
        indentCount: 3,
        indentType: 'Space',
        trimRequestBody: true,
        followRedirect: true
    };
codegen.convert(language, variant, request, options, function(error, snippet) {
    if (error) {
        //  handle error
    }
    //  handle snippet
});

Development

Installing dependencies

This command will install all the dependencies in production mode.

$ npm install;

To install dev dependencies also for all codegens run:

$ npm run deepinstall dev; 

Testing

To run common repo test as well as tests (common structure test + individual codegen tests) for all the codegens

$ npm test; 

To run structure and individual tests on a single codegen

$ npm test <codegen-name>;
# Here "codege-name" is the folder name of the codegen inside codegens folder

Packaging

To create zipped package of all codegens

$ npm run package;

Note: The zipped package is created inside each codegen's folder.

To create zipped package of a single codegen

$ npm run package <codegen-name>

Contributing

Please take a moment to read our contributing guide to learn about our development process. Open an issue first to discuss potential changes/additions.

License

This software is licensed under Apache-2.0. Copyright Postman, Inc. See the LICENSE.md file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].