- Notifications
You must be signed in to change notification settings - Fork0
HTTP Request snippet generator for many languages & libraries
License
confluentinc/httpsnippet
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
HTTP Request snippet generator formany languages & tools including:
cURL
,HTTPie
,Javascript
,Node
,C
,Java
,PHP
,Objective-C
,Swift
,Python
,Ruby
,C#
,Go
,OCaml
andmore!
Relies on the popularHAR format to import data and describe HTTP calls.
See it in action on companion service:APIembed
# to use in clinpm install --global httpsnippet# to use as a modulenpm install --save httpsnippet
Usage: httpsnippet [options] <file> Options: -h, --help output usage information -V, --version output the version number -t, --target <target> target output -c, --client [client] target client library -o, --output <directory> write output to directory
process single file:example.json
inHAR Request Object format, or fullHAR log format:
httpsnippet example.json --target node --client unirest --output ./snippets
$ tree snippetssnippets/└── example.js
process multiple files:
httpsnippet ./*.json --target node --client request --output ./snippets
$ tree snippets/snippets/├── endpoint-1.js├── endpoint-2.js└── endpoint-3.js
RequiredType:object
Name ofconversion target
varHTTPSnippet=require('httpsnippet');varsnippet=newHTTPSnippet({method:'GET',url:'http://mockbin.com/request'});
RequiredType:string
Name ofconversion target
Type:object
Target options,seewiki for details
varHTTPSnippet=require('httpsnippet');varsnippet=newHTTPSnippet({method:'GET',url:'http://mockbin.com/request'});// generate Node.js: Native outputconsole.log(snippet.convert('node'));// generate Node.js: Native output, indent with tabsconsole.log(snippet.convert('node',{indent:'\t'}));
RequiredType:string
Name ofconversion target
Type:string
Name of conversion targetclient library
Type:object
Target options,seewiki for details
varHTTPSnippet=require('httpsnippet');varsnippet=newHTTPSnippet({method:'GET',url:'http://mockbin.com/request'});// generate Shell: cURL outputconsole.log(snippet.convert('shell','curl',{indent:'\t'}));// generate Node.js: Unirest outputconsole.log(snippet.convert('node','unirest'));
RequiredType:object
Representation of aconversion target. Can use this to use targets that are not officially supported.
constcustomLanguageTarget=require('httpsnippet-for-my-lang');HTTPSnippet.addTarget(customLanguageTarget);
RequiredType:string
Name ofconversion target
RequiredType:object
Representation of aconversion target client. Can use this to use target clients that are not officially supported.
constcustomClient=require('httpsnippet-for-my-node-http-client');HTTPSnippet.addTargetClient('node',customClient);
At the heart of this module is theHAR Format as the HTTP request description format, please review some of the sample JSON HAR Request objects intest fixtures, or read theHAR Docs for more details.
For detailed information on each target, please review thewiki.
Have a bug or a feature request? Please first read theissue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet,please open a new issue.
Please read through ourcontributing guidelines. Included are directions for opening issues, coding standards, and notes on development.
For info on creating new conversion targets, please review thisguideline
Moreover, if your pull request contains JavaScript patches or features, you must include relevant unit tests.
Editor preferences are available in theeditor config for easy use in common text editors. Read more and download plugins athttp://editorconfig.org.
For transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible.
Releases will be numbered with the following format:
<major>.<minor>.<patch>
And constructed with the following guidelines:
- Breaking backward compatibilitybumps the major while resetting minor and patch
- New additions without breaking backward compatibilitybumps the minor while resetting the patch
- Bug fixes and misc changesbumps only the patch
For more information on SemVer, please visithttp://semver.org/.
About
HTTP Request snippet generator for many languages & libraries
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- JavaScript99.9%
- Dockerfile0.1%