GithubHelp home page GithubHelp logo

andersha / swagger-play2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ayush/swagger-play2

0.0 1.0 0.0 179 KB

Enables Swagger on Play 2.0

Home Page: http://swagger.wordnik.com

Java 7.56% Scala 92.44%

swagger-play2's Introduction

NOTE: This is not longer maintained

We've moved the official swagger-play2 module to here:

https://github.com/wordnik/swagger-core/tree/master/modules/swagger-play2

There is also a sample project to get you started:

https://github.com/wordnik/swagger-core/tree/master/samples/scala-play2


****************************************************
Swagger for Play 2.0 Apps

>>>>>INSTALLATION
0. This works with Play 2.0 

1. Clone, build and deploy this fork of swagger-core using "ant deploy". This fork works with scala 2.9.1 which Play 2.0 requires and has additional annotations for supporting Play 2.0 style controllers.
https://github.com/ayush/swagger-core

2. Clone swagger-play2 from https://github.com/ayush/swagger-play2

3. Deploy swagger-play2 using play2's publish-local command

4. In YOUR APP's Build.scala, add this dependency
  	"swagger-play2" %% "swagger-play2" % "1.0"

5. In YOUR APP, do reload/update and swagger-play2 should be present.

>>>>>USAGE - routes file
in YOUR APP's routes add these lines:
# Swagger - Root Resources Listing
GET  /resources.json  		controllers.ApiHelpController.getResources
GET  /resources.xml				controllers.ApiHelpController.getResources

# Swagger - Resources
GET  /admin.json				controllers.ApiHelpController.getResource(path = "/admin")
GET  /admin.xml					controllers.ApiHelpController.getResource(path = "/admin")

GET  /admin.json/health			controllers.AdminController.getHealth()
GET  /admin.xml/health			controllers.AdminController.getHealth()
GET  /admin.json/ping			controllers.AdminController.ping()
GET  /admin.xml/ping			controllers.AdminController.ping()

>>>>>USAGE - controllers
For Swagger to recognize your controller methods as API point, you can add the following annotations to a controller method:
  @Path("/add-employee")  
  @ApiOperation(value = "Add a new employee", notes = "", responseClass = "string", httpMethod = "POST")
  @ApiParamsImplicit(Array( 
  new ApiParamImplicit(name = "id", value = "id of employee", required = true, dataType = "string", paramType = "query"),
  	new ApiParamImplicit(name = "name", value = "Name of employee", required = true, dataType = "string", paramType = "query"),
  	new ApiParamImplicit(name = "salary", value = "The salary which the poor soul gets", required = true, dataType = "string", paramType = "query")
  ))
  def addEmployee() = Action { implicit request =>
     // get the params and do the jig
  }

swagger-play2's People

Contributors

ayush avatar fehguy avatar jurrchen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.