Gathering detailed insights and metrics for @paloaltonetworks/postman-code-generators
Gathering detailed insights and metrics for @paloaltonetworks/postman-code-generators
Gathering detailed insights and metrics for @paloaltonetworks/postman-code-generators
Gathering detailed insights and metrics for @paloaltonetworks/postman-code-generators
npm install @paloaltonetworks/postman-code-generators
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Latest Version
1.1.15-patch.2
Package Id
@paloaltonetworks/postman-code-generators@1.1.15-patch.2
Unpacked Size
0.99 MB
Size
110.40 kB
File Count
299
NPM Version
8.19.3
Node Version
18.13.0
Published on
Mar 17, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
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.
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 |
To install postman-code-generators as your dependency
1$ npm install postman-code-generators
To get a copy on your local machine
1$ git clone https://github.com/postmanlabs/postman-code-generators.git
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.
There are three functions that are exposed in postman-code-generators: getLanguageList, getOptions, and convert.
This function returns a list of supported code generators.
1var codegen = require('postman-code-generators'), // require postman-code-generators in your project 2 supportedCodegens = codegen.getLanguageList(); 3 console.log(supportedCodegens); 4 // output: 5 // [ 6 // { 7 // key: 'nodejs', 8 // label: 'NodeJs', 9 // syntax_mode: 'javascript', 10 // variant: [ 11 // { 12 // key: 'Requests' 13 // }, 14 // { 15 // key: 'Native' 16 // }, 17 // { 18 // key: 'Unirest' 19 // } 20 // ] 21 // }, 22 // ... 23 // ]
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 functionvariant
- variant key provided by getLanguageList functioncallback
- 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 nameid
- unique ID of the optiontype
- 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 snippetdescription
- User friendly description.1var codegen = require('postman-code-generators'), // require postman-code-generators in your project 2 language = 'nodejs', 3 variant = 'Request'; 4 5 codegen.getOptions(language, variant, function (error, options) { 6 if (error) { 7 // handle error 8 } 9 console.log(options); 10 }); 11// output: 12// [ 13// { 14// name: 'Set indentation count', 15// id: 'indentCount', 16// type: 'positiveInteger', 17// default: 2, 18// description: 'Set the number of indentation characters to add per code level' 19// }, 20// { 21// name: 'Set indentation type', 22// id: 'indentType', 23// type: 'enum', 24// availableOptions: ['Tab', 'Space'], 25// default: 'Space', 26// description: 'Select the character used to indent lines of code' 27// }, 28// ... 29// ];
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 functionvariant
- variant key provided by getLanguageList functionrequest
- Postman-SDK Request Objectoptions
- Options that can be used to configure generated code snippet. Defaults will be used for the unspecified attributescallback
- callback function with first parameter as error and second parameter as string for code snippet1var codegen = require('postman-code-generators'), // require postman-code-generators in your project 2 sdk = require('postman-collection'), // require postman-collection in your project 3 request = new sdk.Request('https://www.google.com'), //using postman sdk to create request 4 language = 'nodejs', 5 variant = 'request', 6 options = { 7 indentCount: 3, 8 indentType: 'Space', 9 trimRequestBody: true, 10 followRedirect: true 11 }; 12codegen.convert(language, variant, request, options, function(error, snippet) { 13 if (error) { 14 // handle error 15 } 16 // handle snippet 17});
This command will install all the dependencies in production mode.
1$ npm install;
To install dev dependencies also for all codegens run:
1$ npm run deepinstall dev;
To run common repo test as well as tests (common structure test + individual codegen tests) for all the codegens
1$ npm test;
To run structure and individual tests on a single codegen
1$ npm test <codegen-name>; 2# Here "codege-name" is the folder name of the codegen inside codegens folder
To create zipped package of all codegens
1$ npm run package;
Note: The zipped package is created inside each codegen's folder.
To create zipped package of a single codegen
1$ npm run package <codegen-name>
Please take a moment to read our contributing guide to learn about our development process. Open an issue first to discuss potential changes/additions.
This software is licensed under Apache-2.0. Copyright Postman, Inc. See the LICENSE.md file for more information.
No vulnerabilities found.
No security vulnerabilities found.