All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spice.openapi.OpenAPIContent.scala Maven / Gradle / Ivy

There is a newer version: 0.6.1
Show newest version
package spice.openapi

import fabric._
import fabric.define.DefType
import fabric.rw._
import spice.net.ContentType

case class OpenAPIContent(content: List[(ContentType, OpenAPIContentType)])

object OpenAPIContent {
  implicit val rw: RW[OpenAPIContent] = RW.from(
    r = c => obj(c.content.map {
      case (ct, oct) => ct.toString -> oct.json
    }: _*),
    w = j => OpenAPIContent(j.asMap.map {
      case (ct, oct) => ContentType.parse(ct) -> oct.as[OpenAPIContentType]
    }.toList),
    d = DefType.Null
  )

  def apply(content: (ContentType, OpenAPIContentType)*): OpenAPIContent = OpenAPIContent(content.toList)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy