8.
Server
Code
API
Document
SDKs
Specification
Document
as a reference
Manually developed resources
9.
Server
Code
API
Document
SDKs
Specification
Document
Samples
Mock Server
API Console
Test code
Manually developed resources
as a reference
10.
Server
Code
API
Document
SDKs
Samples
Mock Server
API Console
Test code
Manually developed resources
incorrect
or
doesn’t exist
Sometimes…
11.
To avoid publishing un-updatable APIs
• API changing is not so difficult,
• if you can ignore lots of resources.
• e.g. SDKs, Documents, Tests, Clients, …
13.
Server
Code
API
Document
SDKs
API
Schema
generate/validate
SamplesAPI ConsoleMock Server
Non-manually developed resources
codegenswagger-UIswagger-node
swagger-spec
swagger-editor
swagger-js
17.
Server : Swagger-Node
swagger project create [project name]
swagger project edit
1. Generate a template for express | hapi | restify | sails
2. Write API specs
vim api/controller/[controller file name].js
3. Write controllers that meet the API specs
18.
filename of the controllers
name of the controller
19.
Client : Swagger-js
var swagger = new SwaggerClient({
url: "http://localhost:8080/swagger.yaml",
success: function() {
swagger.apis.hackernews.fetch(
{page:api}, {responseContentType: 'application/
json'},
function(res) {
:
});
}
});
Dynamically Swagger SDK for JavaScript
20.
Client : Swagger-js with React
var self = this;
var swagger = new SwaggerClient({
url: "http://localhost:8080/swagger.yaml",
success: function() {
swagger.apis.hackernews.fetch(
{page:api}, {responseContentType: 'application/json'},
function(res) {
self.setState({data:res.obj});
});
}
});
at componentDidMount
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.
Be the first to comment