From b07d51d436101cff1945290626e8484beda7bc9e Mon Sep 17 00:00:00 2001 From: David van Geest Date: Fri, 25 Jun 2021 23:03:07 -0400 Subject: [PATCH 1/2] Make authorizationUrl optional. --- .../src/main/scala/sttp/tapir/apispec/SecurityScheme.scala | 2 +- core/src/main/scala/sttp/tapir/EndpointIO.scala | 2 +- core/src/main/scala/sttp/tapir/TapirAuth.scala | 4 ++-- .../scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala b/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala index 9a31119264..24547d3bd2 100644 --- a/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala +++ b/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/SecurityScheme.scala @@ -23,7 +23,7 @@ case class OAuthFlows( ) case class OAuthFlow( - authorizationUrl: String, + authorizationUrl: Option[String], tokenUrl: Option[String], refreshUrl: Option[String], scopes: ListMap[String, String], diff --git a/core/src/main/scala/sttp/tapir/EndpointIO.scala b/core/src/main/scala/sttp/tapir/EndpointIO.scala index 0b82af4a75..fb519d5532 100644 --- a/core/src/main/scala/sttp/tapir/EndpointIO.scala +++ b/core/src/main/scala/sttp/tapir/EndpointIO.scala @@ -206,7 +206,7 @@ object EndpointInput { override def securitySchemeName(name: String): Http[T] = copy(securitySchemeName = Some(name)) } case class Oauth2[T]( - authorizationUrl: String, + authorizationUrl: Option[String], tokenUrl: Option[String], scopes: ListMap[String, String], refreshUrl: Option[String], diff --git a/core/src/main/scala/sttp/tapir/TapirAuth.scala b/core/src/main/scala/sttp/tapir/TapirAuth.scala index f1da2e2ad0..591f4c0d85 100644 --- a/core/src/main/scala/sttp/tapir/TapirAuth.scala +++ b/core/src/main/scala/sttp/tapir/TapirAuth.scala @@ -32,8 +32,8 @@ object TapirAuth { object oauth2 { def authorizationCode( - authorizationUrl: String, - scopes: ListMap[String, String], + authorizationUrl: Option[String] = None, + scopes: ListMap[String, String] = ListMap(), tokenUrl: Option[String] = None, refreshUrl: Option[String] = None, challenge: WWWAuthenticate = WWWAuthenticate.bearer() diff --git a/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala b/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala index 069e372bbc..d72a9b598a 100644 --- a/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala +++ b/examples/src/main/scala/sttp/tapir/examples/OAuth2GithubHttp4sServer.scala @@ -38,7 +38,7 @@ object OAuth2GithubHttp4sServer extends App { case class AccessDetails(token: String) - val authorizationUrl = "https://github.com/login/oauth/authorize" + val authorizationUrl = Some("https://github.com/login/oauth/authorize") val accessTokenUrl = Some("https://github.com/login/oauth/access_token") val authOAuth2 = auth.oauth2.authorizationCode(authorizationUrl, ListMap.empty, accessTokenUrl) From 2f5da55e74a93c8b89ff52ada8dab037ea614377 Mon Sep 17 00:00:00 2001 From: David van Geest Date: Sat, 26 Jun 2021 22:17:05 -0400 Subject: [PATCH 2/2] Fix test compilation error. --- .../scala/sttp/tapir/docs/openapi/VerifyYamlSecurityTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlSecurityTest.scala b/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlSecurityTest.scala index d32dbf7752..75e921bd0a 100644 --- a/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlSecurityTest.scala +++ b/docs/openapi-docs/src/test/scala/sttp/tapir/docs/openapi/VerifyYamlSecurityTest.scala @@ -57,7 +57,7 @@ class VerifyYamlSecurityTest extends AnyFunSuite with Matchers { val oauth2 = auth.oauth2 .authorizationCode( - "https://example.com/auth", + Some("https://example.com/auth"), ListMap("client" -> "scope for clients", "admin" -> "administration scope") )