Skip to content

Commit

Permalink
Cosmetics - reverted changes in whitespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kloch committed Dec 14, 2023
1 parent f65ea65 commit 7a9d408
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 145 deletions.
142 changes: 71 additions & 71 deletions core/src/main/scala/sttp/tapir/EndpointIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ object EndpointInput extends EndpointInputMacros {

/** An input with authentication credentials metadata, used when generating documentation. */
case class Auth[T, TYPE <: AuthType](
input: Single[T],
challenge: WWWAuthenticateChallenge,
authType: TYPE,
info: AuthInfo
) extends Single[T] {
input: Single[T],
challenge: WWWAuthenticateChallenge,
authType: TYPE,
info: AuthInfo
) extends Single[T] {
override private[tapir] type ThisType[X] = Auth[X, TYPE]
override def show: String = if (isInputEmpty) s"auth(-)"
else
Expand Down Expand Up @@ -285,11 +285,11 @@ object EndpointInput extends EndpointInputMacros {
}
case class ApiKey() extends AuthType
case class OAuth2(
authorizationUrl: Option[String],
tokenUrl: Option[String],
scopes: ListMap[String, String],
refreshUrl: Option[String]
) extends AuthType {
authorizationUrl: Option[String],
tokenUrl: Option[String],
scopes: ListMap[String, String],
refreshUrl: Option[String]
) extends AuthType {
def requiredScopes(requiredScopes: Seq[String]): ScopedOAuth2 = ScopedOAuth2(this, requiredScopes)
}
case class ScopedOAuth2(oauth2: OAuth2, requiredScopes: Seq[String]) extends AuthType {
Expand All @@ -298,12 +298,12 @@ object EndpointInput extends EndpointInputMacros {
}

case class AuthInfo(
securitySchemeName: Option[String],
description: Option[String],
attributes: AttributeMap,
group: Option[String],
bearerFormat: Option[String]
) {
securitySchemeName: Option[String],
description: Option[String],
attributes: AttributeMap,
group: Option[String],
bearerFormat: Option[String]
) {
def securitySchemeName(name: String): AuthInfo = copy(securitySchemeName = Some(name))
def description(d: String): AuthInfo = copy(description = Some(d))
def group(g: String): AuthInfo = copy(group = Some(g))
Expand All @@ -325,12 +325,12 @@ object EndpointInput extends EndpointInputMacros {
}

case class Pair[T, U, TU](
left: EndpointInput[T],
right: EndpointInput[U],
private[tapir] val combine: CombineParams,
private[tapir] val split: SplitParams
) extends EndpointInput[TU]
with EndpointTransput.Pair[TU] {
left: EndpointInput[T],
right: EndpointInput[U],
private[tapir] val combine: CombineParams,
private[tapir] val split: SplitParams
) extends EndpointInput[TU]
with EndpointTransput.Pair[TU] {
override private[tapir] type ThisType[X] = EndpointInput[X]
override def map[V](m: Mapping[TU, V]): EndpointInput[V] = MappedPair[T, U, TU, V](this, m)
}
Expand All @@ -351,10 +351,10 @@ object EndpointOutput extends EndpointOutputMacros {
//

case class StatusCode[T](
documentedCodes: Map[Either[sttp.model.StatusCode, StatusCodeRange], Info[Unit]],
codec: Codec[sttp.model.StatusCode, T, TextPlain],
info: Info[T]
) extends Atom[T] {
documentedCodes: Map[Either[sttp.model.StatusCode, StatusCodeRange], Info[Unit]],
codec: Codec[sttp.model.StatusCode, T, TextPlain],
info: Info[T]
) extends Atom[T] {
override private[tapir] type ThisType[X] = StatusCode[X]
override private[tapir] type L = sttp.model.StatusCode
override private[tapir] type CF = TextPlain
Expand Down Expand Up @@ -411,9 +411,9 @@ object EndpointOutput extends EndpointOutputMacros {
* checking the run-time class of the value, due to type erasure (if `O` has type parameters).
*/
case class OneOfVariant[O] private[tapir] (
output: EndpointOutput[O],
appliesTo: Any => Boolean
)
output: EndpointOutput[O],
appliesTo: Any => Boolean
)

case class OneOf[O, T](variants: List[OneOfVariant[_ <: O]], mapping: Mapping[O, T]) extends Single[T] {
override private[tapir] type ThisType[X] = OneOf[O, X]
Expand Down Expand Up @@ -441,12 +441,12 @@ object EndpointOutput extends EndpointOutputMacros {
}

case class Pair[T, U, TU](
left: EndpointOutput[T],
right: EndpointOutput[U],
private[tapir] val combine: CombineParams,
private[tapir] val split: SplitParams
) extends EndpointOutput[TU]
with EndpointTransput.Pair[TU] {
left: EndpointOutput[T],
right: EndpointOutput[U],
private[tapir] val combine: CombineParams,
private[tapir] val split: SplitParams
) extends EndpointOutput[TU]
with EndpointTransput.Pair[TU] {
override private[tapir] type ThisType[X] = EndpointOutput[X]
override def map[V](m: Mapping[TU, V]): EndpointOutput[V] = MappedPair[T, U, TU, V](this, m)
}
Expand Down Expand Up @@ -558,12 +558,12 @@ object EndpointIO {
}

case class Pair[T, U, TU](
left: EndpointIO[T],
right: EndpointIO[U],
private[tapir] val combine: CombineParams,
private[tapir] val split: SplitParams
) extends EndpointIO[TU]
with EndpointTransput.Pair[TU] {
left: EndpointIO[T],
right: EndpointIO[U],
private[tapir] val combine: CombineParams,
private[tapir] val split: SplitParams
) extends EndpointIO[TU]
with EndpointTransput.Pair[TU] {
override private[tapir] type ThisType[X] = EndpointIO[X]
override def map[V](m: Mapping[TU, V]): EndpointIO[V] = MappedPair[T, U, TU, V](this, m)
}
Expand All @@ -585,11 +585,11 @@ object EndpointIO {
Example(value, name, summary, description)

def copy[TT](
value: TT = this.value,
name: Option[String] = this.name,
summary: Option[String] = this.summary,
description: Option[String] = this.description
): Example[TT] = Example(value, name, summary, description)
value: TT = this.value,
name: Option[String] = this.name,
summary: Option[String] = this.summary,
description: Option[String] = this.description
): Example[TT] = Example(value, name, summary, description)
}

object Example {
Expand All @@ -601,11 +601,11 @@ object EndpointIO {
}

case class Info[T](
description: Option[String],
examples: List[Example[T]],
deprecated: Boolean,
attributes: AttributeMap
) {
description: Option[String],
examples: List[Example[T]],
deprecated: Boolean,
attributes: AttributeMap
) {
def description(d: String): Info[T] = copy(description = Some(d))
def example: Option[T] = examples.headOption.map(_.value)
def example(value: T): Info[T] = example(Example.of(value))
Expand Down Expand Up @@ -694,12 +694,12 @@ However, this decreases type safety, as the streaming requirement is lost.
BS == streams.BinaryStream, but we can't express this using dependent types here.
*/
case class StreamBodyIO[BS, T, S](
streams: Streams[S],
codec: Codec[BS, T, CodecFormat],
info: Info[T],
charset: Option[Charset],
encodedExamples: List[Example[Any]]
) extends EndpointTransput.Atom[T] {
streams: Streams[S],
codec: Codec[BS, T, CodecFormat],
info: Info[T],
charset: Option[Charset],
encodedExamples: List[Example[Any]]
) extends EndpointTransput.Atom[T] {
override private[tapir] type ThisType[X] = StreamBodyIO[BS, X, S]
override private[tapir] type L = BS
override private[tapir] type CF = CodecFormat
Expand Down Expand Up @@ -728,20 +728,20 @@ Same rationale as for StreamBodyIO applies.
P == streams.Pipe, but we can't express this using dependent types here.
*/
case class WebSocketBodyOutput[PIPE_REQ_RESP, REQ, RESP, T, S](
streams: Streams[S],
requests: Codec[WebSocketFrame, REQ, CodecFormat],
responses: Codec[WebSocketFrame, RESP, CodecFormat],
codec: Codec[PIPE_REQ_RESP, T, CodecFormat],
info: Info[T],
requestsInfo: Info[REQ],
responsesInfo: Info[RESP],
concatenateFragmentedFrames: Boolean,
ignorePong: Boolean,
autoPongOnPing: Boolean,
decodeCloseRequests: Boolean,
decodeCloseResponses: Boolean,
autoPing: Option[(FiniteDuration, WebSocketFrame.Ping)]
) extends EndpointTransput.Atom[T] {
streams: Streams[S],
requests: Codec[WebSocketFrame, REQ, CodecFormat],
responses: Codec[WebSocketFrame, RESP, CodecFormat],
codec: Codec[PIPE_REQ_RESP, T, CodecFormat],
info: Info[T],
requestsInfo: Info[REQ],
responsesInfo: Info[RESP],
concatenateFragmentedFrames: Boolean,
ignorePong: Boolean,
autoPongOnPing: Boolean,
decodeCloseRequests: Boolean,
decodeCloseResponses: Boolean,
autoPing: Option[(FiniteDuration, WebSocketFrame.Ping)]
) extends EndpointTransput.Atom[T] {
override private[tapir] type ThisType[X] = WebSocketBodyOutput[PIPE_REQ_RESP, REQ, RESP, X, S]
override private[tapir] type L = PIPE_REQ_RESP
override private[tapir] type CF = CodecFormat
Expand Down
82 changes: 41 additions & 41 deletions core/src/main/scala/sttp/tapir/Tapir.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* A supported streams implementation.
*/
def streamBinaryBody[S](
s: Streams[S]
)(format: CodecFormat): StreamBodyIO[s.BinaryStream, s.BinaryStream, S] =
s: Streams[S]
)(format: CodecFormat): StreamBodyIO[s.BinaryStream, s.BinaryStream, S] =
StreamBodyIO(s, Codec.id(format, Schema.binary), EndpointIO.Info.empty, None, Nil)

/** Creates a stream body with a text schema.
Expand All @@ -146,8 +146,8 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* An optional charset of the resulting stream's data, to be used in the content type.
*/
def streamTextBody[S](
s: Streams[S]
)(format: CodecFormat, charset: Option[Charset] = None): StreamBodyIO[s.BinaryStream, s.BinaryStream, S] =
s: Streams[S]
)(format: CodecFormat, charset: Option[Charset] = None): StreamBodyIO[s.BinaryStream, s.BinaryStream, S] =
StreamBodyIO(s, Codec.id(format, Schema.string), EndpointIO.Info.empty, charset, Nil)

/** Creates a stream body with the given schema.
Expand All @@ -161,18 +161,18 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* An optional charset of the resulting stream's data, to be used in the content type.
*/
def streamBody[S, T](
s: Streams[S]
)(schema: Schema[T], format: CodecFormat, charset: Option[Charset] = None): StreamBodyIO[s.BinaryStream, s.BinaryStream, S] =
s: Streams[S]
)(schema: Schema[T], format: CodecFormat, charset: Option[Charset] = None): StreamBodyIO[s.BinaryStream, s.BinaryStream, S] =
StreamBodyIO(s, Codec.id(format, schema.as[s.BinaryStream]), EndpointIO.Info.empty, charset, Nil)

// the intermediate class is needed so that the S type parameter can be inferred
final class WebSocketBodyBuilder[REQ, REQ_CF <: CodecFormat, RESP, RESP_CF <: CodecFormat] {
def apply[S](
s: Streams[S]
)(implicit
requests: Codec[WebSocketFrame, REQ, REQ_CF],
responses: Codec[WebSocketFrame, RESP, RESP_CF]
): WebSocketBodyOutput[s.Pipe[REQ, RESP], REQ, RESP, s.Pipe[REQ, RESP], S] =
s: Streams[S]
)(implicit
requests: Codec[WebSocketFrame, REQ, REQ_CF],
responses: Codec[WebSocketFrame, RESP, RESP_CF]
): WebSocketBodyOutput[s.Pipe[REQ, RESP], REQ, RESP, s.Pipe[REQ, RESP], S] =
WebSocketBodyOutput(
s,
requests,
Expand Down Expand Up @@ -202,8 +202,8 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
def webSocketBody[REQ, REQ_CF <: CodecFormat, RESP, RESP_CF <: CodecFormat]: WebSocketBodyBuilder[REQ, REQ_CF, RESP, RESP_CF] =
new WebSocketBodyBuilder[REQ, REQ_CF, RESP, RESP_CF]
def webSocketBodyRaw[S](
s: Streams[S]
): WebSocketBodyOutput[s.Pipe[WebSocketFrame, WebSocketFrame], WebSocketFrame, WebSocketFrame, s.Pipe[
s: Streams[S]
): WebSocketBodyOutput[s.Pipe[WebSocketFrame, WebSocketFrame], WebSocketFrame, WebSocketFrame, s.Pipe[
WebSocketFrame,
WebSocketFrame
], S] =
Expand Down Expand Up @@ -296,9 +296,9 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* Should be used in [[oneOf]] output descriptions.
*/
def oneOfVariantClassMatcher[T](
output: EndpointOutput[T],
runtimeClass: Class[_]
): OneOfVariant[T] = {
output: EndpointOutput[T],
runtimeClass: Class[_]
): OneOfVariant[T] = {
// when used with a primitive type or Unit, the class tag will correspond to the primitive type, but at runtime
// we'll get boxed values
val rc = primitiveToBoxedClasses.getOrElse(runtimeClass, runtimeClass)
Expand All @@ -311,17 +311,17 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* Should be used in [[oneOf]] output descriptions.
*/
def oneOfVariantClassMatcher[T](
code: StatusCode,
output: EndpointOutput[T],
runtimeClass: Class[_]
): OneOfVariant[T] = oneOfVariantClassMatcher(statusCode(code).and(output), runtimeClass)
code: StatusCode,
output: EndpointOutput[T],
runtimeClass: Class[_]
): OneOfVariant[T] = oneOfVariantClassMatcher(statusCode(code).and(output), runtimeClass)

/** Create a one-of-variant which uses `output` if the provided value (when interpreting as a server matches the `matcher` predicate).
*
* Should be used in [[oneOf]] output descriptions.
*/
def oneOfVariantValueMatcher[T](output: EndpointOutput[T])(
matcher: PartialFunction[Any, Boolean]
matcher: PartialFunction[Any, Boolean]
): OneOfVariant[T] =
OneOfVariant(output, matcher.lift.andThen(_.getOrElse(false)))

Expand All @@ -331,7 +331,7 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* Should be used in [[oneOf]] output descriptions.
*/
def oneOfVariantValueMatcher[T](code: StatusCode, output: EndpointOutput[T])(
matcher: PartialFunction[Any, Boolean]
matcher: PartialFunction[Any, Boolean]
): OneOfVariant[T] =
OneOfVariant(statusCode(code).and(output), matcher.lift.andThen(_.getOrElse(false)))

Expand All @@ -340,11 +340,11 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* Should be used in [[oneOf]] output descriptions.
*/
def oneOfVariantExactMatcher[T: ClassTag](
output: EndpointOutput[T]
)(
firstExactValue: T,
rest: T*
): OneOfVariant[T] =
output: EndpointOutput[T]
)(
firstExactValue: T,
rest: T*
): OneOfVariant[T] =
oneOfVariantValueMatcher(output)(exactMatch(rest.toSet + firstExactValue))

/** Create a one-of-variant which uses `output` if the provided value exactly matches one of the values provided in the second argument
Expand All @@ -353,12 +353,12 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* Should be used in [[oneOf]] output descriptions.
*/
def oneOfVariantExactMatcher[T: ClassTag](
code: StatusCode,
output: EndpointOutput[T]
)(
firstExactValue: T,
rest: T*
): OneOfVariant[T] =
code: StatusCode,
output: EndpointOutput[T]
)(
firstExactValue: T,
rest: T*
): OneOfVariant[T] =
oneOfVariantValueMatcher(code, output)(exactMatch(rest.toSet + firstExactValue))

/** Create a one-of-variant which uses `output` if the provided value matches the target type, as checked by [[MatchType]]. Instances of
Expand Down Expand Up @@ -423,9 +423,9 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* as specified by the body's codec. This is only used when choosing which body to decode.
*/
def oneOfBody[T](
first: (ContentTypeRange, EndpointIO.Body[_, T]),
others: (ContentTypeRange, EndpointIO.Body[_, T])*
): EndpointIO.OneOfBody[T, T] =
first: (ContentTypeRange, EndpointIO.Body[_, T]),
others: (ContentTypeRange, EndpointIO.Body[_, T])*
): EndpointIO.OneOfBody[T, T] =
EndpointIO.OneOfBody[T, T]((first +: others.toList).map { case (r, b) => EndpointIO.OneOfBodyVariant(r, Left(b)) }, Mapping.id)

/** Streaming variant of [[oneOfBody]].
Expand All @@ -434,11 +434,11 @@ trait Tapir extends TapirExtensions with TapirComputedInputs with TapirStaticCon
* as specified by the body's codec. This is only used when choosing which body to decode.
*/
def oneOfBody[T](
first: (ContentTypeRange, EndpointIO.StreamBodyWrapper[_, T]),
// this is needed so that the signature is different from the previous method
second: (ContentTypeRange, EndpointIO.StreamBodyWrapper[_, T]),
others: (ContentTypeRange, EndpointIO.StreamBodyWrapper[_, T])*
): EndpointIO.OneOfBody[T, T] =
first: (ContentTypeRange, EndpointIO.StreamBodyWrapper[_, T]),
// this is needed so that the signature is different from the previous method
second: (ContentTypeRange, EndpointIO.StreamBodyWrapper[_, T]),
others: (ContentTypeRange, EndpointIO.StreamBodyWrapper[_, T])*
): EndpointIO.OneOfBody[T, T] =
EndpointIO.OneOfBody[T, T](
(first +: second +: others.toList).map { case (r, b) => EndpointIO.OneOfBodyVariant(r, Right(b)) },
Mapping.id
Expand Down
Loading

0 comments on commit 7a9d408

Please sign in to comment.