1.0.5 • Published 7 years ago
pb-api-client-gen v1.0.5
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
npm install pb-api-client-gen --save-dev- Create an
apiClients.ymlfile using the example below - Edit your project's
package.jsonfile and add a property namedbuild-apiwith the valuebuild-apito thescriptsobject. 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 generatedswaggerDefinitionUrl- URL of the target swagger definitionoutputDirectory- Destination path of generated clients
Generating API code
- Edit the
package.jsonfile of your project. Use the example below for reference. - Run
npm run build-appto 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
Creating an npm command - http://blog.npmjs.org/post/118810260230/building-a-simple-command-line-tool-with-npm