Coder Social home page Coder Social logo

swagger-finatra's Introduction

swagger-finatra

Add Swagger support for Finatra (1.6 and 2.2.0) web framework.

It requires Java 8 from version 0.6.0.

Getting started

Gradle

Add repository

repositories {
  maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}

Add Dependency

Scala 2.11, Finatra 17.12.0
compile "com.github.xiaodongw:swagger-finatra_2.11:0.7.3-criteo"
Scala 2.10, Finatra 2.2.0
compile "com.github.xiaodongw:swagger-finatra_2.10:0.7.2"
Scala 2.11, Finatra 2.2.0
compile "com.github.xiaodongw:swagger-finatra_2.11:0.7.2"

SBT

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases/"

Add Dependency

Finatra 2.2.0
libraryDependencies += "com.github.xiaodongw" %% "swagger-finatra" % "0.7.2"

Add document information for you controller

object SampleSwagger extends Swagger

class SampleController extends Controller with SwaggerSupport {
  implicit protected val swagger = SampleSwagger

  getWithDoc("/students/:id") { o =>
    o.summary("Read the detail information about the student")
      .tag("Student")
      .routeParam[String]("id", "the student id")
      .responseWith[Student](200, "the student details")
      .responseWith(404, "the student is not found")
  } { request =>
    ...
  }

Add document controller

Finatra 2.2.0
object SampleApp extends HttpServer {
  val info = new Info()
    .description("The Student / Course management API, this is a sample for swagger document generation")
    .version("1.0.1")
    .title("Student / Course Management API")
  SampleSwagger.info(info)

  override def configureHttp(router: HttpRouter) {
    router
      .add[WebjarsController]
      .add(new SwaggerController(swagger = SampleSwagger))
      ...
  }
}

Swagger API document: http://localhost:8888/api-docs/model

Swagger UI: http://localhost:8888/api-docs/ui

Finatra 1.6

Previous version of Finatra (1.6) is also supported, Check here for the guide.

swagger-finatra's People

Contributors

xiaodongw avatar mekajiki avatar devshorts avatar fhoering avatar albertpastrana avatar ikhoon avatar forthy avatar chris-chen-zocdoc avatar

Watchers

Yann Schwartz avatar James Cloos avatar  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.