• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introducing Swagger
 

Introducing Swagger

on

  • 15,044 views

Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services.

Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services.

Statistics

Views

Total Views
15,044
Views on SlideShare
15,001
Embed Views
43

Actions

Likes
13
Downloads
77
Comments
4

7 Embeds 43

https://sendtoinc.com 16
http://us-w1.rockmelt.com 13
http://twitter.com 5
http://www.twylah.com 5
http://www.linkedin.com 2
https://twitter.com 1
https://www.linkedin.com 1
More...

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

14 of 4 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Hi, please join the google group for discussions about getting going with swagger:

    https://groups.google.com/forum/#!forum/swagger-swaggersocket
    Are you sure you want to
    Your message goes here
    Processing…
  • Hi tam
    I am new to programming i want to generate interactive documentation as http://petstore.swagger.wordnik.com/
    For this i have added swagger annotations in java class
    package com.mkyong;

    import javax.ws.rs.Consumes;
    import javax.ws.rs.GET;
    import javax.ws.rs.POST;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.MediaType;
    //import javax.ws.rs.core.Response;

    import com.mkyong.Track;
    import com.wordnik.swagger.core.Api;
    import com.wordnik.swagger.core.ApiErrors;
    import com.wordnik.swagger.core.ApiError;
    import com.wordnik.swagger.core.ApiOperation;

    @Path('/json/metallica')
    @Api(value = '/json/metallica', description = 'Operations about singer')
    public class JSONService {

    @GET
    @Path('/get.json')
    @ApiOperation(value = 'Find singer', notes = 'Add extra notes here', responseClass = 'com.mkyong.JSONService')
    @ApiErrors(value = { @ApiError(code = 400, reason = 'singer not found'),
    @ApiError(code = 404, reason = 'singer not found') })

    @Produces(MediaType.APPLICATION_JSON)
    public Track getTrackInJSON() {

    Track track = new Track();
    track.setTitle('Enter Sandman');
    track.setSinger('Metallica');

    return track;

    }

    /*@POST
    @Path('/post')
    @Consumes(MediaType.APPLICATION_JSON)
    public Response createTrackInJSON(Track track) {

    String result = 'Track saved : ' + track;
    return Response.status(201).entity(result).build();

    }
    */
    }
    And in swagger ui ,in index.html i have given discovery url-http://localhost:8080/RESTfulExample/json/metallica/get.json
    my web.xml is
    jersey-serlvetcom.sun.jersey.spi.container.servlet.ServletContainercom.sun.jersey.config.property.packagescom.mkyongcom.sun.jersey.config.property.packagescom.mkyong;com.wordnik.swagger.jaxrs.listingcom.sun.jersey.api.json.POJOMappingFeaturetrue1jersey-serlvet/rest/*

    I am getting an error cant read swagger json
    it is unable to load swagger ui
    do i need to add anything else ?
    Are you sure you want to
    Your message goes here
    Processing…
  • See here for generating static documentation:

    https://github.com/wordnik/swagger-codegen#generating-static-api-documentation
    Are you sure you want to
    Your message goes here
    Processing…
  • How do i generate documentation of my rest webservices with using swagger annotation only for example @documentation ,could there be such annotation where i provide output path and documentation get automatically generated .Thanks in advance
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Introducing Swagger Introducing Swagger Presentation Transcript

    • Introduction to Swagger
      Tony Tam
      @fehguy
    • Why Swagger?
      Integration with REST APIs is troublesome and inconsistent
      Different vendors have different REST semantics
      Client libraries vary wildly by vendor, language
      Documentation for developers is an afterthought
      Input parameters, allowable values, models, responses are found via trial & error
      Internally a PITA
      YOUR API is too hard to develop against!
    • How Does it Work?
      Your server produces a Resource List
      All available APIs
      http://petstore.swagger.wordnik.com/api/resources.json
      “It’s like a sitemap for your API!”
    • How Does it Work?
      Each API declares itself
      Available operations
      Parameters
      Type (path, query, body)
      Allowable values/data types
      Input/output models
      Error responses with descriptions
    • API Response
      http://petstore.swagger.wordnik.com/api/pet.json
    • API Response
      Knowing input/output models is helpful!
      Based on JSON Schema (Draft)
      http://tools.ietf.org/html/draft-zyp-json-schema-03
    • But what’s the benefit?
      A Sandbox!
    • Client Library Generation
      Code generation based on Resource Spec
      Template-based Framework
      Consume REST Methods, Models, Parameters
      Produce client libraries
      “Know before you go HTTP”
      Required values, fields are known by the client
      Only expose what’s allowed!
      Swagger filtering removes methods/models you don’t have access to
    • Client Library Generation
      Super user access
      Ordinary dev access
    • Test Framework
      JSON-driven tests for your Client + API
      Expected data
      Test Suites
    • Test Framework
    • Easy to add
      For Java/Scala via JAX-RS…
      Add swagger-core.jar
      Annotate your models per your @Providerclass
      Annotate your resources
    • Easy to add
      For node.js via express
      Require swagger.js
      Declare your swagger specs, models
      Could use AST/DSL to do automatically
      Add your operations, configure and start
    • Easy DIY
      The Swagger spec is Language Agnostic!
      ANY swagger-compliant server can…
      Use the Swagger client lib generator
      Use the test framework
      Use the sandbox UI
      More server support from Wordnik
      Play, Rails
      .net, others community developed
    • Where to go Next
      Try Swagger
      swagger.wordnik.com
      See it in action
      developer.wordnik.com/docs
      Download the source/samples
      swagger.wordnik.com/downloads
      Discuss it
      groups.google.com/group/wordnik-api
      #swagger_doc on freenode
    • Questions?