Swagger / JS Meetup 5 mars 2015
©EPFL
Qui êtes vous ?
→ Qui crée des APIs ?
→ Qui consomme des API
→ Combien d’API avez vous utilisées
aujourd’hui ?
Pierre-André Vullioud
watchful.li CTO
Owner of inetis.ch
Joomla enthusiast
@pavullioud
APIs in 2015
source : www.programmableweb.com/api-research
Amazon
→ All teams will expose their data and functionality
through API.
→ There will be no other form of interprocess
communication [..]
→ Anyone who doesn't do this will be fired.
Amazon policy set by Jeff Bezos in 2003
http://apievangelist.com/2012/01/12/the-secret-to-amazons-success-internal-apis/
API centric architecture
→ Internal use
→ Apps
→ Clients
→ Partners
Data
API
Functionality
app
partners
services
Swagger
Language pour décrire des API REST
http://swagger.io/
Description de votre API
JSON
Technologie agnostique
Accélère le développement
Documentation
https://watchful.li/apidoc-v1/index.html
SDK Generator
https://github.com/swagger-api/swagger-codegen
Javascript
Javascript Class
https://github.com/wcandillon/swagger-js-codegen
Générer dynamiquement un client en Javascript
https://github.com/swagger-api/swagger-js
Client dynamique
var swagger = new client.SwaggerClient({
url: 'http://petstore.swagger.wordnik.com/v2/swagger.json',
success: function() {
swagger.apis.pet.getPetById({petId:1});
}
});
Editeur
http://editor.swagger.io/#/
Générer le code
→ avec l’éditeur
→ parser le code source
Exemple PHP
https://github.com/zircote/swagger-php/
Questions ?

Swagger, language pour décrire des API REST