NativeSwaggerBase

org.scalatra.swagger.NativeSwaggerBase
trait NativeSwaggerBase extends ScalatraBase, NativeJsonSupport, CorsSupport, SwaggerBase

Attributes

Graph
Supertypes
trait SwaggerBase
trait CorsSupport
trait NativeJsonSupport
trait JValueResult
trait NativeJsonOutput
trait JsonMethods
trait JsonSupport[Document]
trait JsonOutput[Document]
trait JsonMethods[Document]
trait ApiFormats
trait ScalatraBase
trait DefaultImplicitConversions
trait LowPriorityImplicitConversions
trait LowestPriorityImplicitConversions
trait TypeConverterSupport
trait ScalatraParamsImplicits
trait Initializable
trait DynamicScope
trait RequestResponseScope
trait CoreDsl
trait Control
trait Handler
trait ScalatraContext
trait CookieContext
trait SessionSupport
trait ServletApiImplicits
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited classlikes

trait Config

Attributes

Inherited from:
Initializable
Supertypes
class Object
trait Matchable
class Any
implicit class JsonAssocNonEmpty(left: JObject)

Attributes

Inherited from:
SwaggerBase
Supertypes
class Object
trait Matchable
class Any

Inherited types

type ConfigT

Attributes

Inherited from:
Initializable

Value members

Inherited methods

def acceptHeader(implicit request: HttpServletRequest): List[String]

The list of media types accepted by the current request. Parsed from the Accept header.

The list of media types accepted by the current request. Parsed from the Accept header.

Attributes

Inherited from:
ApiFormats
def after(transformers: RouteTransformer*)(fun: => Any): Unit

Adds a filter to run after the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.

Adds a filter to run after the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.

Attributes

Inherited from:
ScalatraBase
protected def bathPath: Option[String]

Attributes

Inherited from:
SwaggerBase
def before(transformers: RouteTransformer*)(fun: => Any): Unit

Adds a filter to run before the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.

Adds a filter to run before the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.

Attributes

Inherited from:
ScalatraBase
def compact(d: Document): String

Attributes

Inherited from:
JsonMethods
def contentType: String

Gets the content type of the current response.

Gets the content type of the current response.

Attributes

Inherited from:
ScalatraContext
def contentType_=(contentType: String): Unit

Sets the content type of the current response.

Sets the content type of the current response.

Attributes

Inherited from:
ScalatraContext
def cookies(implicit request: HttpServletRequest): SweetCookies

Attributes

Inherited from:
CookieContext
def defaultAcceptedFormats: List[Symbol]

A list of formats accepted by default.

A list of formats accepted by default.

Attributes

Inherited from:
ApiFormats
def defaultFormat: Symbol

The default format.

The default format.

Attributes

Inherited from:
ApiFormats
def delete(transformers: RouteTransformer*)(action: => Any): Route

Attributes

See also

get

Inherited from:
ScalatraBase
def environment: String

Attributes

Inherited from:
ScalatraBase
def error(handler: ErrorHandler): Unit

Defines an error handler for exceptions thrown in either the before block or a route action.

Defines an error handler for exceptions thrown in either the before block or a route action.

If the error handler does not match, the result falls through to the previously defined error handler. The default error handler simply rethrows the exception.

The error handler is run before the after filters, and the result is rendered like a standard response. It is the error handler's responsibility to set any appropriate status code.

Attributes

Inherited from:
ScalatraBase
def format(implicit request: HttpServletRequest, response: HttpServletResponse): String

Returns the request-scoped format. If not explicitly set, the format is: $ - the format request parameter, if present in formatParams $ - the first match from Accept header, looked up in mimeTypes $ - the format from the Content-Type header, as looked up in mimeTypes $ - the default format

Returns the request-scoped format. If not explicitly set, the format is: $ - the format request parameter, if present in formatParams $ - the first match from Accept header, looked up in mimeTypes $ - the format from the Content-Type header, as looked up in mimeTypes $ - the default format

Attributes

Inherited from:
ApiFormats
def format_=(formatValue: String): Unit

Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.

Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.

Attributes

Inherited from:
ScalatraContext
def format_=(formatValue: Symbol): Unit

Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.

Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.

Attributes

Inherited from:
ScalatraContext
def fullUrl(path: String, params: Iterable[(String, Any)], includeContextPath: Boolean, includeServletPath: Boolean, withSessionId: Boolean)(implicit request: HttpServletRequest, response: HttpServletResponse): String

Builds a full URL from the given relative path. Takes into account the port configuration, https, ...

Builds a full URL from the given relative path. Takes into account the port configuration, https, ...

Value parameters

path

a relative path

Attributes

Returns

the full URL

Inherited from:
ScalatraBase
def get(transformers: RouteTransformer*)(action: => Any): Route

The Scalatra DSL core methods take a list of org.scalatra.RouteMatcher and a block as the action body. The return value of the block is rendered through the pipeline and sent to the client as the response body.

The Scalatra DSL core methods take a list of org.scalatra.RouteMatcher and a block as the action body. The return value of the block is rendered through the pipeline and sent to the client as the response body.

See org.scalatra.ScalatraBase#renderResponseBody for the detailed behaviour and how to handle your response body more explicitly, and see how different return types are handled.

The block is executed in the context of a CoreDsl instance, so all the methods defined in this trait are also available inside the block.

 get("/") {
   <form action="/echo">
     <label>Enter your name</label>
     <input type="text" name="name"/>
   </form>
 }

 post("/echo") {
   "hello {params('name)}!"
 }

ScalatraKernel provides implicit transformation from boolean blocks, strings and regular expressions to org.scalatra.RouteMatcher, so you can write code naturally.

 get("/", request.getRemoteHost == "127.0.0.1") { "Hello localhost!" }

Attributes

Inherited from:
ScalatraBase
def halt(result: ActionResult): Nothing

Attributes

Inherited from:
Control
def halt[T](status: Integer, body: T, headers: Map[String, String]): Nothing

Immediately halts processing of a request. Can be called from either a before filter or a route.

Immediately halts processing of a request. Can be called from either a before filter or a route.

Value parameters

body

a result to render through the render pipeline as the body

headers

headers to add to the response

status

the status to set on the response, or null to leave the status unchanged.

Attributes

Inherited from:
Control
def handle(req: HttpServletRequest, res: HttpServletResponse): Unit

Handles a request and writes to the response.

Handles a request and writes to the response.

Attributes

Inherited from:
CorsSupport
def head(transformers: RouteTransformer*)(action: => Any): Route

Attributes

See also

head

Inherited from:
ScalatraBase
protected def includeFormatParameter: Boolean

Whether to include the format parameter in the index listing for swagger defaults to false, the format parameter will not be present but is still optional.

Whether to include the format parameter in the index listing for swagger defaults to false, the format parameter will not be present but is still optional.

Attributes

Returns

true if the format parameter should be included in the returned json

Inherited from:
SwaggerBase
protected def indexRoute: String

The name of the route to use when getting the index listing for swagger defaults to optional resources.:format or /

The name of the route to use when getting the index listing for swagger defaults to optional resources.:format or /

Attributes

Returns

The name of the route

Inherited from:
SwaggerBase
def initParameter(name: String): Option[String]

Gets an init parameter from the config.

Gets an init parameter from the config.

Value parameters

name

the name of the key

Attributes

Returns

an option containing the value of the parameter if defined, or None if the parameter is not set.

Inherited from:
ScalatraBase
def initialize(config: ConfigT): Unit

A hook to initialize the class with some configuration after it has been constructed.

A hook to initialize the class with some configuration after it has been constructed.

Not called init because GenericServlet doesn't override it, and then we get into https://lampsvn.epfl.ch/trac/scala/ticket/2497.

Attributes

Inherited from:
SwaggerBase
def isDevelopmentMode: Boolean

A boolean flag representing whether the kernel is in development mode. The default is true if the environment begins with "dev", case-insensitive.

A boolean flag representing whether the kernel is in development mode. The default is true if the environment begins with "dev", case-insensitive.

Attributes

Inherited from:
ScalatraBase
def jsonpCallbackParameterNames: Iterable[String]

If a request is made with a parameter in jsonpCallbackParameterNames it will be assumed that it is a JSONP request and the json will be returned as the argument to a function with the name specified in the corresponding parameter.

If a request is made with a parameter in jsonpCallbackParameterNames it will be assumed that it is a JSONP request and the json will be returned as the argument to a function with the name specified in the corresponding parameter.

By default no parameterNames will be checked

Attributes

Inherited from:
JsonOutput
def methodNotAllowed(f: Set[HttpMethod] => Any): Unit

Defines a block to run if matching routes are found only for other methods. The set of matching methods is passed to the block.

Defines a block to run if matching routes are found only for other methods. The set of matching methods is passed to the block.

Attributes

Inherited from:
ScalatraBase
def multiParams(implicit request: HttpServletRequest): MultiParams

The current multiparams. Multiparams are a result of merging the standard request params (query string or post params) with the route parameters extracted from the route matchers of the current route. The default value for an unknown param is the empty sequence. Invalid outside handle.

The current multiparams. Multiparams are a result of merging the standard request params (query string or post params) with the route parameters extracted from the route matchers of the current route. The default value for an unknown param is the empty sequence. Invalid outside handle.

Attributes

Inherited from:
ScalatraBase
def multiParams(key: String)(implicit request: HttpServletRequest): Seq[String]

Attributes

Inherited from:
ScalatraBase
def notFound(fun: => Any): Unit

Defines a block to run if no matching routes are found, or if all matching routes pass.

Defines a block to run if no matching routes are found, or if all matching routes pass.

Attributes

Inherited from:
ScalatraBase
def options(transformers: RouteTransformer*)(action: => Any): Route

Attributes

See also

get

Inherited from:
ScalatraBase
def params(implicit request: HttpServletRequest): Params

Attributes

Inherited from:
ScalatraBase
def params(key: String)(implicit request: HttpServletRequest): String

Attributes

Inherited from:
ScalatraBase
def parse[A : AsJsonInput](in: A, useBigDecimalForDouble: Boolean, useBigIntForLong: Boolean): JValue

Attributes

Inherited from:
JsonMethods
override def parseOpt[A : AsJsonInput](in: A, useBigDecimalForDouble: Boolean, useBigIntForLong: Boolean): Option[JValue]

Attributes

Definition Classes
JsonMethods -> JsonMethods
Inherited from:
JsonMethods
def parsedBody(implicit request: HttpServletRequest): JValue

Attributes

Inherited from:
JsonSupport
def pass(): Nothing

Immediately exits from the current route.

Immediately exits from the current route.

Attributes

Inherited from:
Control
def patch(transformers: RouteTransformer*)(action: => Any): Route

Attributes

See also

patch

Inherited from:
ScalatraBase
def post(transformers: RouteTransformer*)(action: => Any): Route

Attributes

See also

get

Inherited from:
ScalatraBase
def pretty(d: Document): String

Attributes

Inherited from:
JsonMethods
def put(transformers: RouteTransformer*)(action: => Any): Route

Attributes

See also

get

Inherited from:
ScalatraBase
protected def readJsonFromBody(bd: String): JValue

Attributes

Inherited from:
NativeJsonSupport
def redirect(uri: String)(implicit request: HttpServletRequest, response: HttpServletResponse): Nothing

Sends a redirect response and immediately halts the current action.

Sends a redirect response and immediately halts the current action.

Attributes

Inherited from:
ScalatraBase
def relativeUrl(path: String, params: Iterable[(String, Any)], includeContextPath: Boolean, includeServletPath: Boolean)(implicit request: HttpServletRequest, response: HttpServletResponse): String

Attributes

Inherited from:
ScalatraBase
def render(value: JValue, alwaysEscapeUnicode: Boolean, emptyValueStrategy: EmptyValueStrategy): Document

Renders JSON.

Renders JSON.

Attributes

See also

Printer#compact

Printer#pretty

Inherited from:
JsonMethods
override protected def renderPipeline: RenderPipeline

The render pipeline is a partial function of Any => Any. It is called recursively until it returns (). () indicates that the response has been rendered.

The render pipeline is a partial function of Any => Any. It is called recursively until it returns (). () indicates that the response has been rendered.

Attributes

Definition Classes
JValueResult -> ScalatraBase
Inherited from:
JValueResult
protected def renderSwagger2(docs: List[Api]): JValue

Attributes

Inherited from:
SwaggerBase
def requestFormat(implicit request: HttpServletRequest): String

Attributes

Inherited from:
ApiFormats
def requestPath(implicit request: HttpServletRequest): String

The effective path against which routes are matched. The definition varies between servlets and filters.

The effective path against which routes are matched. The definition varies between servlets and filters.

Attributes

Inherited from:
ScalatraBase
def secureXML: XMLLoader[Elem]

Attributes

Inherited from:
JsonSupport
def serverHost(implicit request: HttpServletRequest): String

Attributes

Inherited from:
ScalatraBase
def serverPort(implicit request: HttpServletRequest): Int

Attributes

Inherited from:
ScalatraBase
def servletContext: ServletContext

The servlet context in which this kernel runs.

The servlet context in which this kernel runs.

Attributes

Inherited from:
ScalatraBase
def session(key: String)(implicit request: HttpServletRequest): Any

Attributes

Inherited from:
SessionSupport
def sessionOption(implicit request: HttpServletRequest): Option[HttpSession]

The current session. If none exists, None is returned.

The current session. If none exists, None is returned.

Attributes

Inherited from:
SessionSupport
protected def shutdown(): Unit

A hook to shutdown the class. Bridges the gap between servlet's destroy and filter's destroy.

A hook to shutdown the class. Bridges the gap between servlet's destroy and filter's destroy.

Attributes

Inherited from:
Initializable
def status: Int

Gets the status code of the current response.

Gets the status code of the current response.

Attributes

Inherited from:
ScalatraContext
def status_=(code: Int): Unit

Sets the status code of the current response.

Sets the status code of the current response.

Attributes

Inherited from:
ScalatraContext
def stringToDate(format: => String): TypeConverter[String, Date]

Attributes

Inherited from:
DefaultImplicitConversions
def stringToDateFormat(format: => DateFormat): TypeConverter[String, Date]

Attributes

Inherited from:
DefaultImplicitConversions
def stringToSeq[T : ClassTag](elementConverter: TypeConverter[String, T], separator: String): TypeConverter[String, Seq[T]]

Attributes

Inherited from:
DefaultImplicitConversions
def trap(codes: Range)(block: => Any): Unit

Error handler for HTTP response status code range. You can intercept every response code previously specified with #status or even generic 404 error.

Error handler for HTTP response status code range. You can intercept every response code previously specified with #status or even generic 404 error.

 trap(403) {
  "You are not authorized"
 }
}* 

}}

Attributes

Inherited from:
ScalatraBase
def trap(code: Int)(block: => Any): Unit

Attributes

See also

error

Inherited from:
CoreDsl
def url(path: String, params: Iterable[(String, Any)], includeContextPath: Boolean, includeServletPath: Boolean, absolutize: Boolean, withSessionId: Boolean)(implicit request: HttpServletRequest, response: HttpServletResponse): String

Returns a context-relative, session-aware URL for a path and specified parameters. Finally, the result is run through response.encodeURL for a session ID, if necessary.

Returns a context-relative, session-aware URL for a path and specified parameters. Finally, the result is run through response.encodeURL for a session ID, if necessary.

Value parameters

params

params, to be appended in the form of a query string

path

the base path. If a path begins with '/', then the context path will be prepended to the result

Attributes

Returns

the path plus the query string, if any. The path is run through response.encodeURL to add any necessary session tracking parameters.

Inherited from:
ScalatraBase
protected def withRequest[A](request: HttpServletRequest)(f: => A): A

Executes the block with the given request bound to the request method.

Executes the block with the given request bound to the request method.

Attributes

Inherited from:
DynamicScope
protected def withResponse[A](response: HttpServletResponse)(f: => A): A

Executes the block with the given response bound to the response method.

Executes the block with the given response bound to the response method.

Attributes

Inherited from:
DynamicScope
protected def writeJson(json: JValue, writer: Writer): Unit

Attributes

Inherited from:
NativeJsonOutput

Inherited fields

var config: ConfigT

The configuration, typically a ServletConfig or FilterConfig.

The configuration, typically a ServletConfig or FilterConfig.

Attributes

Inherited from:
ScalatraBase
val formats: Map[String, String]

A map of suffixes to content types.

A map of suffixes to content types.

Attributes

Inherited from:
ApiFormats
val mimeTypes: Map[String, String]

A map of content types to suffixes. Not strictly a reverse of formats.

A map of content types to suffixes. Not strictly a reverse of formats.

Attributes

Inherited from:
ApiFormats
lazy val routes: RouteRegistry

The routes registered in this kernel.

The routes registered in this kernel.

Attributes

Inherited from:
ScalatraBase

Implicits

Inherited implicits

final implicit def JsonAssocNonEmpty(left: JObject): JsonAssocNonEmpty

Attributes

Inherited from:
SwaggerBase
implicit val anyToBoolean: TypeConverter[Any, Boolean]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit val anyToByte: TypeConverter[Any, Byte]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit val anyToDouble: TypeConverter[Any, Double]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit val anyToFloat: TypeConverter[Any, Float]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit val anyToInt: TypeConverter[Any, Int]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit val anyToLong: TypeConverter[Any, Long]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit val anyToShort: TypeConverter[Any, Short]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit val anyToString: TypeConverter[Any, String]

Attributes

Inherited from:
LowPriorityImplicitConversions
implicit protected def configWrapper(config: ConfigT): Config

Attributes

Inherited from:
Initializable
implicit def cookieOptions: CookieOptions

Attributes

Inherited from:
CookieContext
implicit def defaultStringToSeq[T : ClassTag](implicit evidence$1: ClassTag[T], elementConverter: TypeConverter[String, T]): TypeConverter[String, Seq[T]]

Attributes

Inherited from:
DefaultImplicitConversions
implicit protected def docToJson(doc: Api): JValue

Attributes

Inherited from:
SwaggerBase
implicit def enrichRequest(request: HttpServletRequest): RichRequest

Attributes

Inherited from:
ServletApiImplicits
implicit def enrichResponse(response: HttpServletResponse): RichResponse

Attributes

Inherited from:
ServletApiImplicits
implicit def enrichServletContext(servletContext: ServletContext): RichServletContext

Attributes

Inherited from:
ServletApiImplicits
implicit def enrichSession(session: HttpSession): RichSession

Attributes

Inherited from:
ServletApiImplicits
implicit protected def jsonFormats: Formats

Attributes

Inherited from:
SwaggerBase
implicit def lowestPriorityAny2T[T : ClassTag]: TypeConverter[Any, T]

Attributes

Inherited from:
LowestPriorityImplicitConversions
implicit def request: HttpServletRequest

The currently scoped request. Valid only inside the handle method.

The currently scoped request. Valid only inside the handle method.

Attributes

Inherited from:
DynamicScope
implicit def response: HttpServletResponse

The currently scoped response. Valid only inside the handle method.

The currently scoped response. Valid only inside the handle method.

Attributes

Inherited from:
DynamicScope
implicit def safe[S, T](f: S => T): TypeConverter[S, T]

Attributes

Inherited from:
TypeConverterSupport
implicit def safeOption[S, T](f: S => Option[T]): TypeConverter[S, T]

Implicit convert a (String) => Option[T] function into a TypeConverter[T]

Implicit convert a (String) => Option[T] function into a TypeConverter[T]

Attributes

Inherited from:
TypeConverterSupport
implicit def seqHead[T : ClassTag](implicit evidence$3: ClassTag[T], elementConverter: TypeConverter[String, T]): TypeConverter[Seq[String], T]

Attributes

Inherited from:
DefaultImplicitConversions
implicit def seqToSeq[T : ClassTag](implicit evidence$4: ClassTag[T], elementConverter: TypeConverter[String, T]): TypeConverter[Seq[String], Seq[T]]

Attributes

Inherited from:
DefaultImplicitConversions
implicit def session(implicit request: HttpServletRequest): HttpSession

The current session. Creates a session if none exists.

The current session. Creates a session if none exists.

Attributes

Inherited from:
SessionSupport
implicit override def string2RouteMatcher(path: String): RailsRouteMatcher

Attributes

Definition Classes
Inherited from:
SwaggerBase
implicit val stringToBoolean: TypeConverter[String, Boolean]

Attributes

Inherited from:
DefaultImplicitConversions
implicit val stringToByte: TypeConverter[String, Byte]

Attributes

Inherited from:
DefaultImplicitConversions
implicit val stringToDouble: TypeConverter[String, Double]

Attributes

Inherited from:
DefaultImplicitConversions
implicit val stringToFloat: TypeConverter[String, Float]

Attributes

Inherited from:
DefaultImplicitConversions
implicit val stringToInt: TypeConverter[String, Int]

Attributes

Inherited from:
DefaultImplicitConversions
implicit val stringToLong: TypeConverter[String, Long]

Attributes

Inherited from:
DefaultImplicitConversions
implicit val stringToSelf: TypeConverter[String, String]

Attributes

Inherited from:
DefaultImplicitConversions
implicit val stringToShort: TypeConverter[String, Short]

Attributes

Inherited from:
DefaultImplicitConversions
implicit protected def swagger: SwaggerEngine

Returns the Swagger instance responsible for generating the resource and operation listings.

Returns the Swagger instance responsible for generating the resource and operation listings.

Attributes

Inherited from:
SwaggerBase
implicit def toTypedMultiParams(params: MultiParams): TypedMultiParams

Attributes

Inherited from:
ScalatraParamsImplicits
implicit def toTypedParams(params: Params): TypedParams

Attributes

Inherited from:
ScalatraParamsImplicits