Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
anilcse committed Sep 22, 2019
1 parent 569caec commit cd0b454
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

JS-SDKGen is JavaScript API SDK Code generator, based on json file generated for api docs by Swagger or apidocjs or optionally your own json file with any shape with transform function. It just requires a apidoc definition (swagger and apidocjs genenrated api docs aslo supported now) and it generates the JavaScript SDK for you. Thus eliminate the work of writing your own SDK. It can run in both browser(a tool can be made) and node.

clone the repo
## Installation

```sh
npm install -g js-sdkgen
js-sdkgen --json-file=api-docs.json name=MySDK --version=1.0.0 base-url=http://vitwit.com/api --requiredHeaders accoundId,key --optionalHeaders name
js-sdkgen --json-file=api-docs.json name=MySDK --version=1.0.0 base-url=https://vitwit.com/api --requiredHeaders accoundId,key --optionalHeaders name
```

Below are parameter available for node cli while generating SDK.
Expand Down Expand Up @@ -50,7 +50,7 @@ mySDK.getHeader("Header1");
Example cli parameters to set MandatoryHeader1, MandatoryHeader2 as required headers, you just need to keep `true` after the header name. If the variable is set to `false` or left blank, it will be considered as Optional Header by the program.

```sh
js-sdkgen --json-file api-docs.json --name=MySDK --version=1.0.0 --base-url=http://vitwit.com/api --requiredHeaders a,b,c --optionalHeaders d,e,f
js-sdkgen --json-file api-docs.json --name=MySDK --version=1.0.0 --base-url=https://vitwit.com/api --requiredHeaders a,b,c --optionalHeaders d,e,f
```

these configs can overridden or more configs can be passed from frontend before intiating the class as below.
Expand All @@ -60,7 +60,7 @@ these configs can overridden or more configs can be passed from frontend before
mySDK.setHeader("Authorization", "Bearer <yourtokenhere>");

//override existing config, i.e., baseUrl
mySDK.setBaseUrl("http://api.vitwit.com/v2");
mySDK.setBaseUrl("https://api.vitwit.com/v2");

// you can also get any header value set by you calling getHeader
mySDK.getHeader("Authorization");
Expand Down Expand Up @@ -100,7 +100,6 @@ This JavaScript file can name export these two function.
any where in your application you can call sdk methods like this, provide it body data obj while calling, you can pass formdata same as this and it will internally will do `(new FormData).append(key,value)` wherever needed.

```js
import mySDK from "./path-of-file";
async function handleSignIn(name, password) {
const { data, error } = await mySDK.signIn({
name,
Expand Down Expand Up @@ -135,7 +134,7 @@ You don't have to deal with calling API's, managing API constants, handling erro
On top of that if backend change data structure of response, they can provide a object `transformOperations` with key as operationName functions which
will take current data structure and provide the previous version for one who opt to use old version.

### What Next
### TODO

- make a browser tool
- make it generate Reducers for react, handle calling them using action creator internally
[ ] Standardize SDK Usage Guide generation
[ ] Testscripts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vitwit/js-sdkgen",
"version": "1.0.5",
"version": "2.0.1",
"description": "JavaScript SDK generator from api doc's json file, go-docs and swagger support by default,or any json file with given shape.",
"main": "src/index.js",
"bin": {
Expand Down

0 comments on commit cd0b454

Please sign in to comment.