client_code_generators 0.3.0 copy "client_code_generators: ^0.3.0" to clipboard
client_code_generators: ^0.3.0 copied to clipboard

Converts HTTP requests into different languages of your choice, generating HTTP request code for the same language.

Client Code Generators #

Converts HTTP requests into different languages of your choice, generating HTTP request code for the same language.

It is a package written in dart based on Postman's postman-code-generators package

How to use #

language - The language of the code snippet to be generated. The list of supported languages can be found variant - The variant of the code snippet to be generated. The list of supported variants can be found request - The request object to be converted into code snippet options - The options object for the snippet generation callback - The callback function to be called after the snippet is generated


List of supported code generators:

language variant
Dart http

List of supported options:

option type description
trimRequestBody boolean Whether to trim request body fields
indentType string The type of indentation to be used in the generated code snippet. Can be Tab or Space
indentCount number The number of tabs or spaces to be used for indentation
requestTimeout number The timeout value for the request in millisecond
followRedirect boolean Whether to follow redirects for the request
includeBoilerplate boolean Whether to include boilerplate code for the snippet

List of supported body types:

type description content-type
raw Raw json data application/json
urlencoded URL encoded form data application/x-www-form-urlencoded
formdata Multipart form data multipart/form-data
file File data multipart/form-data
graphql GraphQL query application/graphql
none No body none

Getting Started

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  client_code_generators: ^0.3.0

You can install packages from the command line:

$ dart pub get

Usage #

A simple usage example:

import 'package:client_code_generators/client_code_generators.dart';

main() {
  final request =
        Request('GET', 'https://jsonplaceholder.typicode.com/users');

    var options = {
      'trimRequestBody': true,
      'indentType': 'Space',
      'indentCount': 2,
      'requestTimeout': 0,
      'followRedirect': true,
      'includeBoilerplate': true
    };
    var language = 'Dart';
    var variant = 'http';
    
    convert(language, variant, request, options, (error, snippet) {
      print(snippet);
    });
}

Testing #

$ dart test ./..

Contributing #

Before opening an issue or pull request, please check the project's contribution documents.

Please read CONTRIBUTING.md for details about our code of conduct, and the process for submitting pull requests.

Support Donate #

If you find this project useful, you can buy author a glass of juice 🧃

ko-fi

also a coffee ☕️

Buy Me A Coffee

will be very grateful to you for your support 😊.

1
likes
120
pub points
0%
popularity

Publisher

unverified uploader

Converts HTTP requests into different languages of your choice, generating HTTP request code for the same language.

Repository (GitHub)
View/report issues
Contributing

Topics

#code-generators #client

Documentation

API reference

License

MIT (LICENSE)

Dependencies

http, test

More

Packages that depend on client_code_generators