Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulo-lopes-estevao/client-code-generators
Repository for all code generators provided by clients
https://github.com/paulo-lopes-estevao/client-code-generators
client clientao code-generation dart http http-client insomnia postman
Last synced: 2 days ago
JSON representation
Repository for all code generators provided by clients
- Host: GitHub
- URL: https://github.com/paulo-lopes-estevao/client-code-generators
- Owner: Paulo-Lopes-Estevao
- License: mit
- Created: 2023-05-03T18:36:56.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2023-05-21T02:38:09.000Z (over 1 year ago)
- Last Synced: 2024-11-13T19:39:34.515Z (2 days ago)
- Topics: client, clientao, code-generation, dart, http, http-client, insomnia, postman
- Language: Dart
- Homepage: https://pub.dev/packages/client_code_generators
- Size: 42 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/postmanlabs/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:
```yaml
dependencies:
client_code_generators: ^0.3.0
```You can install packages from the command line:
```bash
$ dart pub get
```## Usage
A simple usage example:```dart
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
```bash
$ dart test ./..
```## Contributing
Before opening an issue or pull request, please check the project's contribution documents.
Please read [CONTRIBUTING.md](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](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/E1E2L169R)
also a coffee ☕️
will be very grateful to you for your support 😊.