From d8bae71b8e680c223df7d3005feb2a649ffa4aa3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Jul 2017 23:26:49 +0800 Subject: [PATCH] update JS petstore samples --- .../petstore/javascript-promise/README.md | 27 ++++++++++++++++++- samples/client/petstore/javascript/README.md | 27 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 6ad6f81b3f5..420c2e76e26 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -23,6 +23,30 @@ Then install it via: npm install swagger_petstore --save ``` +##### Local development + +To use the library locally without publishing to a remote npm registry, first install the dependencies by changing +into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run: + +```shell +npm install +``` + +Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`: + +```shell +npm link +``` + +Finally, switch to the directory you want to use your swagger_petstore from, and run: + +```shell +npm link /path/to/ +``` + +You should now be able to `require('swagger_petstore')` in javascript files from the directory you ran the last +command above from. + #### git # If the library is hosted at a git repository, e.g. @@ -37,7 +61,8 @@ then install it via: The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following the above steps with Node.js and installing browserify with `npm install -g browserify`, -perform the following (assuming *main.js* is your entry file): +perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually +use this library): ```shell browserify main.js > bundle.js diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index a58e731b223..de95e8d8001 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -23,6 +23,30 @@ Then install it via: npm install swagger_petstore --save ``` +##### Local development + +To use the library locally without publishing to a remote npm registry, first install the dependencies by changing +into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run: + +```shell +npm install +``` + +Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`: + +```shell +npm link +``` + +Finally, switch to the directory you want to use your swagger_petstore from, and run: + +```shell +npm link /path/to/ +``` + +You should now be able to `require('swagger_petstore')` in javascript files from the directory you ran the last +command above from. + #### git # If the library is hosted at a git repository, e.g. @@ -37,7 +61,8 @@ then install it via: The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following the above steps with Node.js and installing browserify with `npm install -g browserify`, -perform the following (assuming *main.js* is your entry file): +perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually +use this library): ```shell browserify main.js > bundle.js