Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some Endpoint method lazy vals #3551

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading