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

endpoints4s.openapi.Assets.scala Maven / Gradle / Ivy

There is a newer version: 5.0.1
Show newest version
package endpoints4s
package openapi

import endpoints4s.algebra.Documentation
import endpoints4s.openapi.model._

/**
  * Interpreter for [[algebra.Assets]]
  *
  * @group interpreters
  */
trait Assets extends algebra.Assets with EndpointsWithCustomErrors with StatusCodes {

  type AssetRequest = Nothing
  type AssetPath = Nothing
  type AssetResponse = Nothing

  def assetSegments(
      name: String,
      description: Option[String]
  ): Path[AssetPath] =
    DocumentedUrl(
      Right(
        DocumentedParameter(
          name,
          required = true,
          description,
          Schema.simpleString
        )
      ) :: Nil,
      Nil
    )

  def assetsEndpoint(
      url: Url[AssetPath],
      docs: Documentation,
      notFoundDocs: Documentation
  ): Endpoint[AssetRequest, AssetResponse] =
    endpoint(
      DocumentedRequest(Get, url, emptyRequestHeaders, None, emptyRequest),
      DocumentedResponse(
        OK,
        docs.getOrElse(""),
        emptyResponseHeaders,
        Map.empty
      ) ::
        DocumentedResponse(
          NotFound,
          notFoundDocs.getOrElse(""),
          emptyResponseHeaders,
          Map.empty
        ) ::
        Nil
    )

  def digests: Map[String, String] = Map.empty

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy