{"id":13583427,"url":"https://github.com/postmanlabs/postman-code-generators","last_synced_at":"2025-05-14T14:07:50.136Z","repository":{"id":38348168,"uuid":"181494579","full_name":"postmanlabs/postman-code-generators","owner":"postmanlabs","description":"Common repository for all code generators shipped with Postman","archived":false,"fork":false,"pushed_at":"2025-03-10T09:28:15.000Z","size":7945,"stargazers_count":1016,"open_issues_count":103,"forks_count":360,"subscribers_count":33,"default_branch":"develop","last_synced_at":"2025-04-21T12:06:01.674Z","etag":null,"topics":["code-generators","converter","postman","postman-collection"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postmanlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-15T13:38:39.000Z","updated_at":"2025-04-16T23:56:51.000Z","dependencies_parsed_at":"2024-01-18T08:46:58.972Z","dependency_job_id":"30c9e880-d9b4-44d5-a4be-9cbd04b5124d","html_url":"https://github.com/postmanlabs/postman-code-generators","commit_stats":{"total_commits":1154,"total_committers":52,"mean_commits":"22.192307692307693","dds":0.6863084922010398,"last_synced_commit":"c9f05272cdb7137e8ed5a37b02adba7f70bf01cd"},"previous_names":["postmanlabs/code-generators"],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fpostman-code-generators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fpostman-code-generators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fpostman-code-generators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fpostman-code-generators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postmanlabs","download_url":"https://codeload.github.com/postmanlabs/postman-code-generators/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159194,"owners_count":22024558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generators","converter","postman","postman-collection"],"created_at":"2024-08-01T15:03:28.285Z","updated_at":"2025-05-14T14:07:50.046Z","avatar_url":"https://github.com/postmanlabs.png","language":"JavaScript","readme":"\n\u003ca href=\"https://www.getpostman.com/\"\u003e\u003cimg src=\"https://assets.getpostman.com/common-share/postman-logo-horizontal-320x132.png\" /\u003e\u003c/a\u003e\u003cbr /\u003e\n_Manage all of your organization's APIs in Postman, with the industry's most complete API development environment._\n\n*Supercharge your API workflow.*  \n*Modern software is built on APIs. Postman helps you develop APIs faster.*\n\n# postman-code-generators\n\nThis module converts a [Postman SDK](https://github.com/postmanlabs/postman-collection) Request [Object](https://www.postmanlabs.com/postman-collection/Request.html) into a code snippet of chosen language.\n\nEvery code generator has two identifiers: `language` and `variant`.\n* `language` of a code generator is the programming language in which the code snippet is generated.\n* `variant` of a code generator is the methodology or the underlying library used by the language to send requests. \n \nList of supported code generators: \n\n| Language | Variant        |\n|-----------|---------------|\n| C | libcurl |\n| C# | HttpClient |\n| C# | RestSharp | \n| cURL | cURL | \n| Dart | http | \n| Go | Native | \n| HTTP | HTTP | \n| Java | OkHttp |\n| Java | Unirest |\n| JavaScript | Fetch | \n| JavaScript | jQuery | \n| JavaScript | XHR |\n| Kotlin | OkHttp |\n| NodeJs | Axios | \n| NodeJs | Native |\n| NodeJs | Request |\n| NodeJs | Unirest |\n| Objective-C| NSURLSession|\n| OCaml | Cohttp | \n| PHP | cURL |\n| PHP | Guzzle |\n| PHP | pecl_http |\n| PHP | HTTP_Request2 |\n| PowerShell | RestMethod | \n| Python | http.client |\n| Python | Requests |\n| R | httr |\n| R | RCurl |\n| Rust | Reqwest |\n| Ruby | Net:HTTP |\n| Shell | Httpie |\n| Shell | wget |\n| Swift | URLSession | \n## Table of contents \n\n- [postman-code-generators\n  - [Table of contents](#table-of-contents)\n  - [Getting Started](#getting-started)\n  - [Prerequisite](#prerequisite)\n  - [Usage](#usage)\n    - [Using postman-code-generators as a Library](#using-postman-code-generators-as-a-library)\n      - [getLanguageList](#getlanguagelist)\n        - [Example:](#example)\n      - [getOptions](#getoptions)\n        - [Example:](#example-1)\n      - [convert](#convert)\n        - [Example:](#example-2)\n  - [Development](#development)\n    - [Installing dependencies](#installing-dependencies)\n    - [Testing](#testing)\n    - [Packaging](#packaging)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n## Getting Started\nTo install postman-code-generators as your dependency\n```bash\n$ npm install postman-code-generators\n```\nTo get a copy on your local machine\n```bash\n$ git clone https://github.com/postmanlabs/postman-code-generators.git\n```\n\n## Prerequisite\nTo run any of the postman-code-generators, ensure that you have NodeJS \u003e= v8. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager.\n\n## Usage\n\n### Using postman-code-generators as a Library \nThere are three functions that are exposed in postman-code-generators: getLanguageList, getOptions, and convert.\n\n#### getLanguageList\nThis function returns a list of supported code generators. \n\n##### Example:\n```js\nvar codegen = require('postman-code-generators'), // require postman-code-generators in your project\n    supportedCodegens = codegen.getLanguageList();\n    console.log(supportedCodegens);\n    // output:\n    // [\n    //   {\n    //     key: 'nodejs',\n    //     label: 'NodeJs',\n    //     syntax_mode: 'javascript',\n    //     variant: [\n    //       {\n    //         key: 'Requests'\n    //       },\n    //       {\n    //         key: 'Native'\n    //       },\n    //       {\n    //         key: 'Unirest'\n    //       }\n    //     ]\n    //   },\n    //   ...\n    // ]\n```\n\n#### getOptions \n\nThis function takes in three parameters and returns a callback  with error and supported options of that code generator.\n\n* `language` - language key from the language list returned from getLanguageList function\n* `variant` - variant key provided by getLanguageList function\n* `callback` - callback function with first parameter as error and second parameter as array of options supported by the codegen.\n\nA typical option has the following properties:\n* `name` - Display name\n* `id` - unique ID of the option\n* `type` - Data type of the option. (Allowed data types: `boolean`, `enum`, `positiveInteger`)\n* `default` - Default value. The value that is used if this option is not specified while creating code snippet\n* `description` - User friendly description.\n\n##### Example:\n```js\nvar codegen = require('postman-code-generators'), // require postman-code-generators in your project\n    language = 'nodejs',\n    variant = 'Request';\n\n    codegen.getOptions(language, variant, function (error, options) {\n      if (error) {\n        // handle error\n      }\n      console.log(options);\n    });\n// output: \n//     [\n//     {\n//       name: 'Set indentation count',\n//       id: 'indentCount',\n//       type: 'positiveInteger',\n//       default: 2,\n//       description: 'Set the number of indentation characters to add per code level'\n//     },\n//     {\n//       name: 'Set indentation type',\n//       id: 'indentType',\n//       type: 'enum',\n//       availableOptions: ['Tab', 'Space'],\n//       default: 'Space',\n//       description: 'Select the character used to indent lines of code'\n//     },\n//     ...\n//   ];\n```\n\n#### convert \nThis function takes in five parameters and returns a callback with error and generated code snippet\n* `language` - lang key from the language list returned from getLanguageList function\n* `variant` - variant key provided by getLanguageList function\n* `request` - [Postman-SDK](https://github.com/postmanlabs/postman-collection) Request [Object](https://www.postmanlabs.com/postman-collection/Request.html)\n* `options` - Options that can be used to configure generated code snippet. Defaults will be used for the unspecified attributes  \n* `callback` - callback function with first parameter as error and second parameter as string for code snippet\n\n##### Example:\n```js\nvar codegen = require('postman-code-generators'), // require postman-code-generators in your project\n    sdk = require('postman-collection'), // require postman-collection in your project\n    request = new sdk.Request('https://www.google.com'),  //using postman sdk to create request \n    language = 'nodejs',\n    variant = 'request',\n    options = {\n        indentCount: 3,\n        indentType: 'Space',\n        trimRequestBody: true,\n        followRedirect: true\n    };\ncodegen.convert(language, variant, request, options, function(error, snippet) {\n    if (error) {\n        //  handle error\n    }\n    //  handle snippet\n});\n```\n## Development\n\n\n### Installing dependencies\nThis command will install all the dependencies in production mode.\n```bash\n$ npm install;\n```\nTo install dev dependencies also for all codegens run: \n```bash\n$ npm run deepinstall dev; \n```\n### Testing \nTo run common repo test as well as tests (common structure test + individual codegen tests) for all the codegens\n```bash\n$ npm test; \n```\nTo run structure and individual tests on a single codegen\n```bash\n$ npm test \u003ccodegen-name\u003e;\n# Here \"codege-name\" is the folder name of the codegen inside codegens folder\n```\n### Packaging \nTo create zipped package of all codegens\n```bash\n$ npm run package;\n```\n**Note:** The zipped package is created inside each codegen's folder.\n\nTo create zipped package of a single codegen\n```bash\n$ npm run package \u003ccodegen-name\u003e\n```\n\n## Contributing\nPlease take a moment to read our [contributing guide](https://github.com/postmanlabs/postman-code-generators/blob/master/CONTRIBUTING.md) to learn about our development process.\nOpen an [issue](https://github.com/postmanlabs/postman-code-generators/issues) first to discuss potential changes/additions.\n\n## License\nThis software is licensed under Apache-2.0. Copyright Postman, Inc. See the [LICENSE.md](LICENSE.md) file for more information.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmanlabs%2Fpostman-code-generators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostmanlabs%2Fpostman-code-generators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmanlabs%2Fpostman-code-generators/lists"}