Skip to content

Commit

Permalink
Make some Endpoint method lazy vals (#3551)
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski authored Feb 29, 2024
1 parent 7cede65 commit 485a616
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/main/scala/sttp/tapir/Endpoint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,15 @@ trait EndpointMetaOps {
/** Shortened information about the endpoint. If the endpoint is named, returns the name, e.g. `[my endpoint]`. Otherwise, returns the
* string representation of the method (if any) and path, e.g. `POST /books/add`
*/
def showShort: String = info.name match {
lazy val showShort: String = info.name match {
case None => s"${method.map(_.toString()).getOrElse("*")} ${showPathTemplate(showQueryParam = None)}"
case Some(name) => s"[$name]"
}

/** Basic information about the endpoint, excluding mapping information, with inputs sorted (first the method, then path, etc.). E.g.:
* `POST /books /add {header Authorization} {body as application/json (UTF-8)} -> {body as text/plain (UTF-8)}/-`
*/
def show: String = {
lazy val show: String = {
def showOutputs(o: EndpointOutput[_]): String = showOneOf(o.asBasicOutputsList.map(os => showMultiple(os.sortByType)))

val namePrefix = info.name.map("[" + _ + "] ").getOrElse("")
Expand All @@ -367,7 +367,7 @@ trait EndpointMetaOps {
* Endpoint(securityin: -, in: /books POST /add {body as application/json (UTF-8)} {header Authorization}, errout: {body as text/plain (UTF-8)}, out: -)
* }}}
*/
def showDetail: String =
lazy val showDetail: String =
s"$showType${info.name.map("[" + _ + "]").getOrElse("")}(securityin: ${securityInput.show}, in: ${input.show}, errout: ${errorOutput.show}, out: ${output.show})"
protected def showType: String

Expand Down Expand Up @@ -401,7 +401,7 @@ trait EndpointMetaOps {
/** The method defined in a fixed method input in this endpoint, if any (using e.g. [[EndpointInputsOps.get]] or
* [[EndpointInputsOps.post]]).
*/
def method: Option[Method] = {
lazy val method: Option[Method] = {
import sttp.tapir.internal._
input.method.orElse(securityInput.method)
}
Expand Down

0 comments on commit 485a616

Please sign in to comment.