Snapshot của postmanlabs/postman-code-generators: 1.0k★ · JavaScript. Common repository for all code generators shipped with Postman
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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.
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.
Đọc thêm về postmanlabs/postman-code-generators ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/postmanlabs/postman-code-generators là nguồn chính thức.
postmanlabs/postman-code-generators có bao nhiêu sao?
postmanlabs/postman-code-generators có 1.0k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/postmanlabs/postman-code-generators. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
postmanlabs/postman-code-generators có phải mã nguồn mở không?
Có — postmanlabs/postman-code-generators phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/postmanlabs/postman-code-generators.
postmanlabs/postman-code-generators còn đang phát triển không?
Commit gần nhất trên postmanlabs/postman-code-generators là 2 tháng trước (theo timestamp GitHub). Repo có 382 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
postmanlabs/postman-code-generators là gì?
postmanlabs/postman-code-generators (postmanlabs/postman-code-generators) là dự án JavaScript trên GitHub. Theo mô tả gốc: Common repository for all code generators shipped with Postman
Đọc đầy đủ README ở tab phía trên.
Chưa chắc postman-code-generators có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về postman-code-generators.