Swagger support - BlueOakJS/generator-blueoak GitHub Wiki
Swagger support
At build time, the front end build scripts will compile any swagger files (.json or .yaml) that reside in common/swagger into angular services. The name of the service is based on the filename of the swagger file (e.g. petstore.json will be compiled to a 'Petstore' service). The names of the operations are derived from the name specified in the swagger file.
To use the service, inject the service, and call it with a hash of the parameters for the operation. For example:
example.$inject = [
'Petstore'
];
function example(Petstore) {
Petstore.findPetsByStatus({status: 'available'}).then(
function(res) {
console.log(res);
},
function(err) {
console.log(err);
}
);
}
The URL used by the service will default to the URL specified in the swagger file. If you'd like to change it, you can call setURL during the angular config phase. Example:
myApp.config(setPetstoreConfig);
setPetstoreConfig.$inject = [
'Petstore'
];
function setPetstoreConfig(Petstore) {
Petstore.setURL('http://example.com');
};