1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.technical
21 
22 import akka.http.scaladsl.server.Directives
23 import com.github.swagger.akka.SwaggerHttpService
24 import com.github.swagger.akka.model.{Contact, Info}
25 import io.swagger.models.Scheme
26 import io.swagger.models.auth.{OAuth2Definition, SecuritySchemeDefinition}
27 
28 import scala.jdk.CollectionConverters._
29 import scalaoauth2.provider.OAuthGrantType
30 
31 class MakeDocumentation(override val apiClasses: Set[Class[_]], ssl: Boolean)
32     extends SwaggerHttpService
33     with Directives {
34 
35   override def info: Info = Info(
36     title = "Make.org API",
37     description = "The following definition represents the Make.org API.",
38     contact = Some(Contact(name = "Technical team", url = "https://make.org/FR/contact", email = "technique@make.org"))
39   )
40 
41   override def schemes: List[Scheme] =
42     if (ssl) {
43       List(Scheme.HTTPS)
44     } else {
45       List(Scheme.HTTP)
46     }
47 
48   override val securitySchemeDefinitions: Map[String, SecuritySchemeDefinition] = Map("MakeApi" -> {
49     val definition = new OAuth2Definition()
50     definition.setFlow(OAuthGrantType.IMPLICIT)
51     definition.setAuthorizationUrl("/oauth/authenticate")
52     definition.setType("oauth2")
53     definition.setScopes(Map("user" -> "application user", "admin" -> "application admin").asJava)
54     definition
55   })
56 
57 }
Line Stmt Id Pos Tree Symbol Tests Code
35 37869 1276 - 1276 Select com.github.swagger.akka.model.Info.apply$default$7 com.github.swagger.akka.model.`package`.Info.apply$default$7
35 41972 1276 - 1276 Select com.github.swagger.akka.model.Info.apply$default$6 com.github.swagger.akka.model.`package`.Info.apply$default$6
35 51176 1276 - 1508 Apply com.github.swagger.akka.model.Info.apply com.github.swagger.akka.model.`package`.Info.apply("The following definition represents the Make.org API.", x$4, "Make.org API", x$5, x$3, x$6, x$7)
35 49540 1276 - 1276 Select com.github.swagger.akka.model.Info.apply$default$4 com.github.swagger.akka.model.`package`.Info.apply$default$4
35 35771 1276 - 1276 Select com.github.swagger.akka.model.Info.apply$default$2 com.github.swagger.akka.model.`package`.Info.apply$default$2
36 42259 1294 - 1308 Literal <nosymbol> "Make.org API"
37 34740 1328 - 1383 Literal <nosymbol> "The following definition represents the Make.org API."
38 44637 1399 - 1504 Apply scala.Some.apply scala.Some.apply[com.github.swagger.akka.model.Contact](com.github.swagger.akka.model.`package`.Contact.apply("Technical team", "https://make.org/FR/contact", "technique@make.org"))
38 30544 1404 - 1503 Apply com.github.swagger.akka.model.Contact.apply com.github.swagger.akka.model.`package`.Contact.apply("Technical team", "https://make.org/FR/contact", "technique@make.org")
42 43059 1557 - 1560 Select org.make.api.technical.MakeDocumentation.ssl MakeDocumentation.this.ssl
43 35190 1570 - 1588 Apply scala.collection.IterableFactory.apply scala.`package`.List.apply[io.swagger.models.Scheme](HTTPS)
43 31303 1570 - 1588 Block scala.collection.IterableFactory.apply scala.`package`.List.apply[io.swagger.models.Scheme](HTTPS)
45 44400 1608 - 1625 Apply scala.collection.IterableFactory.apply scala.`package`.List.apply[io.swagger.models.Scheme](HTTP)
45 36835 1608 - 1625 Block scala.collection.IterableFactory.apply scala.`package`.List.apply[io.swagger.models.Scheme](HTTP)
48 49581 1719 - 1728 Literal <nosymbol> "MakeApi"
48 50376 1715 - 2035 Apply scala.collection.MapFactory.apply scala.Predef.Map.apply[String, io.swagger.models.auth.OAuth2Definition](scala.Predef.ArrowAssoc[String]("MakeApi").->[io.swagger.models.auth.OAuth2Definition]({ val definition: io.swagger.models.auth.OAuth2Definition = new io.swagger.models.auth.OAuth2Definition(); definition.setFlow(scalaoauth2.provider.OAuthGrantType.`package`.IMPLICIT); definition.setAuthorizationUrl("/oauth/authenticate"); definition.setType("oauth2"); definition.setScopes(scala.jdk.CollectionConverters.MapHasAsJava[String, String](scala.Predef.Map.apply[String, String](scala.Predef.ArrowAssoc[String]("user").->[String]("application user"), scala.Predef.ArrowAssoc[String]("admin").->[String]("application admin"))).asJava); definition }))
48 37345 1719 - 2034 Apply scala.Predef.ArrowAssoc.-> scala.Predef.ArrowAssoc[String]("MakeApi").->[io.swagger.models.auth.OAuth2Definition]({ val definition: io.swagger.models.auth.OAuth2Definition = new io.swagger.models.auth.OAuth2Definition(); definition.setFlow(scalaoauth2.provider.OAuthGrantType.`package`.IMPLICIT); definition.setAuthorizationUrl("/oauth/authenticate"); definition.setType("oauth2"); definition.setScopes(scala.jdk.CollectionConverters.MapHasAsJava[String, String](scala.Predef.Map.apply[String, String](scala.Predef.ArrowAssoc[String]("user").->[String]("application user"), scala.Predef.ArrowAssoc[String]("admin").->[String]("application admin"))).asJava); definition })
49 41727 1755 - 1777 Apply io.swagger.models.auth.OAuth2Definition.<init> new io.swagger.models.auth.OAuth2Definition()
50 51218 1782 - 1825 Apply io.swagger.models.auth.OAuth2Definition.setFlow definition.setFlow(scalaoauth2.provider.OAuthGrantType.`package`.IMPLICIT)
50 37305 1801 - 1824 Select scalaoauth2.provider.OAuthGrantType.IMPLICIT scalaoauth2.provider.OAuthGrantType.`package`.IMPLICIT
51 42810 1830 - 1883 Apply io.swagger.models.auth.OAuth2Definition.setAuthorizationUrl definition.setAuthorizationUrl("/oauth/authenticate")
52 35232 1888 - 1916 Apply io.swagger.models.auth.OAuth2Definition.setType definition.setType("oauth2")
53 47715 1946 - 1974 Apply scala.Predef.ArrowAssoc.-> scala.Predef.ArrowAssoc[String]("user").->[String]("application user")
53 36344 1942 - 2007 Apply scala.collection.MapFactory.apply scala.Predef.Map.apply[String, String](scala.Predef.ArrowAssoc[String]("user").->[String]("application user"), scala.Predef.ArrowAssoc[String]("admin").->[String]("application admin"))
53 49334 1942 - 2014 Select scala.collection.convert.AsJavaExtensions.MapHasAsJava.asJava scala.jdk.CollectionConverters.MapHasAsJava[String, String](scala.Predef.Map.apply[String, String](scala.Predef.ArrowAssoc[String]("user").->[String]("application user"), scala.Predef.ArrowAssoc[String]("admin").->[String]("application admin"))).asJava
53 41765 1921 - 2015 Apply io.swagger.models.auth.OAuth2Definition.setScopes definition.setScopes(scala.jdk.CollectionConverters.MapHasAsJava[String, String](scala.Predef.Map.apply[String, String](scala.Predef.ArrowAssoc[String]("user").->[String]("application user"), scala.Predef.ArrowAssoc[String]("admin").->[String]("application admin"))).asJava)
53 43842 1976 - 2006 Apply scala.Predef.ArrowAssoc.-> scala.Predef.ArrowAssoc[String]("admin").->[String]("application admin")