https://github.com/pointblue/pb-api-client-gen
Javascript API Client Generator
https://github.com/pointblue/pb-api-client-gen
Last synced: 6 days ago
JSON representation
Javascript API Client Generator
- Host: GitHub
- URL: https://github.com/pointblue/pb-api-client-gen
- Owner: pointblue
- Created: 2018-01-23T16:50:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-26T20:36:50.000Z (about 8 years ago)
- Last Synced: 2025-03-04T14:02:02.534Z (over 1 year ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Javascript API Client Generator
Generate a Javascript API client from a swagger document, using swagger client
generator.
This project just makes it easier to define and generate API clients.
## Installation
All commands must be run from the root path of your project
1. `npm install pb-api-client-gen --save-dev`
2. Create an `apiClients.yml` file using the example below
3. Edit your project's `package.json` file and add a property named `build-api` with the value `build-api` to the
`scripts` object. Use the example below for reference.
## Creating an `apiClients.yml` file
`apiClients.yml` should be in the root path of your project. This file defines the clients that will be generated.
### Example file
```
- name: SpeciesRequest
swaggerDefinitionUrl: http://localhost/api/docs/v3/species.swagger.yaml
outputDirectory: resources/js/angular/apiRequest/
```
### Properties
The following properties are required for each client that will be generated:
- `name` - The name of the class that will be generated
- `swaggerDefinitionUrl` - URL of the target swagger definition
- `outputDirectory` - Destination path of generated clients
## Generating API code
1. Edit the `package.json` file of your project. Use the example below for reference.
2. Run `npm run build-app` to generate the client code.
Example:
```
"scripts": {
"build-api": "build-api"
}
```
## Notes
This project is mostly a wrapper for [https://github.com/wcandillon/swagger-js-codegen](https://github.com/wcandillon/swagger-js-codegen)
Creating an npm command - [http://blog.npmjs.org/post/118810260230/building-a-simple-command-line-tool-with-npm](http://blog.npmjs.org/post/118810260230/building-a-simple-command-line-tool-with-npm)