diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f615a2b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [0.1.0] - 2020-01-05 + +### Added +- First release of the project +- CHANGELOG.md file +- README.md file + +[0.1.0]: https://github.com/jjzcru/swagger-ui-loader/releases/tag/v0.1.0 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc78b3f --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +## Installation + +### Npm +```console +npm install swagger-ui-loader --save-dev +``` + +### Yarn +```console +yarn add swagger-ui-loader --dev +``` + +## Usage +Add a run script that executes `swagger-ui-loader`. Your `package.json` should look similar to this. Now just run `npm run swagger`. + +```json +{ + "name": "i-am-your-package🤖", + "scripts": { + "swagger": "swagger-ui-loader" + }, + "devDependencies": { + "swagger-ui-loader": "^0.1.0" + } +} +``` + +Be default it will search for `swagger.json`, `swagger.yml` or `swagger.yaml` on the root directory of the project and it will run a server on port `5466`. + +You can add a property `swagger` to `package.json` with the following properties: + +- `file`: The path on which the file with the swagger data is located. +- `port`: The port on which you want the server to run. + +The `package.json` will look like this with those properties. +```json +{ + "name": "i-am-your-package🤖", + "scripts": { + "swagger": "swagger-ui-loader" + }, + "swagger": { + "file": "./docs/swagger.yml", + "port": 8888, + }, + "devDependencies": { + "swagger-ui-loader": "^0.1.0" + } +} +``` + +If you run `npm run swagger` it will search for the `swagger.yml` inside the `docs` directory and the server will run on port `8888`. \ No newline at end of file diff --git a/cli.js b/cli.js index 48e8b94..eb4cd91 100755 --- a/cli.js +++ b/cli.js @@ -59,10 +59,10 @@ function getTargetFile() { ext: ext } default: - throwError(`File extension '${ext}' is not valid`) + throwError(`File extension '${ext}' is not valid`); } - throwError(`Swagger configuration file '${filePath}' do not exist`) + throwError(`Swagger configuration file '${filePath}' do not exist`); } // I search for 'swagger.yml', 'swagger.yaml' or 'swagger.json' as default value