UNPKG

swag-ng

Version:

Angular module for Swagger API integrations

25 lines (23 loc) 703 B
require('angular'); require('swagNg'); module.exports = angular.module('TestSwagger', ['swagNg']) .value('swagUrl', 'http://petstore.swagger.wordnik.com/api/api-docs/') .controller('TestSwaggerController', function TestSwaggerController($scope, swagNg) { swagNg.then(function (api) { api.pet.addPet({ body: JSON.stringify({ id: 1, name: 'SwaggerDog' }) }, function () { api.pet.getPetById({petId: 1}, function (p) { $scope.$apply(function() { $scope.pet = JSON.parse(p.data); }); }); }); }); });