Skip to content

Commit

Permalink
Merge pull request #43 from virtualeconomy/bugfix/swagger-ui
Browse files Browse the repository at this point in the history
Fix error of swagger ui
  • Loading branch information
ncying authored Apr 1, 2019
2 parents 026d997 + 3448c94 commit b8b3857
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 40 deletions.
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sbt._
object Dependencies {

def akkaModule(module: String) = "com.typesafe.akka" %% s"akka-$module" % "2.4.19"
def swaggerModule(module: String) = "io.swagger" % s"swagger-$module" % "1.5.16"
def swaggerModule(module: String) = ("io.swagger" % s"swagger-$module" % "1.5.22").exclude("com.google.guava", "guava")
def akkaHttpModule(module: String) = "com.typesafe.akka" %% module % "10.0.9"
def nettyModule(module: String) = "io.netty" % s"netty-$module" % "4.1.24.Final"
def kamonModule(module: String) = "io.kamon" %% s"kamon-$module" % "0.6.7"
Expand Down Expand Up @@ -54,7 +54,7 @@ object Dependencies {

lazy val http = Seq("core", "annotations", "models", "jaxrs").map(swaggerModule) ++ Seq(
"io.swagger" %% "swagger-scala-module" % "1.0.4",
"com.github.swagger-akka-http" %% "swagger-akka-http" % "0.9.2",
"com.github.swagger-akka-http" %% "swagger-akka-http" % "1.0.0",
akkaHttpModule("akka-http")
)

Expand Down
46 changes: 23 additions & 23 deletions src/main/scala/com/wavesplatform/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,29 @@ class Application(val actorSystem: ActorSystem, val settings: VsysSettings) exte
DbApiRoute(settings.restAPISettings, wallet, utxStorage, allChannels, time, stateReader)
)

val apiTypes = Seq(
typeOf[BlocksApiRoute],
typeOf[TransactionsApiRoute],
typeOf[SposConsensusApiRoute],
typeOf[WalletApiRoute],
typeOf[PaymentApiRoute],
typeOf[UtilsApiRoute],
typeOf[PeersApiRoute],
typeOf[AddressApiRoute],
typeOf[DebugApiRoute],
//typeOf[WavesApiRoute],
//typeOf[AssetsApiRoute],
typeOf[NodeApiRoute],
//typeOf[AssetsBroadcastApiRoute],
typeOf[LeaseApiRoute],
typeOf[LeaseBroadcastApiRoute],
//typeOf[AliasApiRoute],
//typeOf[AliasBroadcastApiRoute],
typeOf[SPOSApiRoute],
typeOf[SPOSBroadcastApiRoute],
//typeOf[ContractApiRoute],
//typeOf[ContractBroadcastApiRoute],
typeOf[DbApiRoute]
val apiTypes: Set[Class[_]] = Set(
classOf[BlocksApiRoute],
classOf[TransactionsApiRoute],
classOf[SposConsensusApiRoute],
classOf[WalletApiRoute],
classOf[PaymentApiRoute],
classOf[UtilsApiRoute],
classOf[PeersApiRoute],
classOf[AddressApiRoute],
classOf[DebugApiRoute],
//classOf[WavesApiRoute],
//classOf[AssetsApiRoute],
classOf[NodeApiRoute],
//classOf[AssetsBroadcastApiRoute],
classOf[LeaseApiRoute],
classOf[LeaseBroadcastApiRoute],
//classOf[AliasApiRoute],
//classOf[AliasBroadcastApiRoute],
classOf[SPOSApiRoute],
classOf[SPOSBroadcastApiRoute],
//classOf[ContractApiRoute],
//classOf[ContractBroadcastApiRoute],
classOf[DbApiRoute]
)

for (addr <- settings.networkSettings.declaredAddress if settings.networkSettings.uPnPSettings.enable) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/com/wavesplatform/matcher/Matcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import vsys.wallet.Wallet

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.reflect.runtime.universe._

class Matcher(actorSystem: ActorSystem,
wallet: Wallet,
Expand All @@ -33,8 +32,8 @@ class Matcher(actorSystem: ActorSystem,
MatcherApiRoute(wallet, stateReader, matcher, orderHistory, txWriter, restAPISettings, matcherSettings)
)

lazy val matcherApiTypes = Seq(
typeOf[MatcherApiRoute]
lazy val matcherApiTypes: Set[Class[_]] = Set(
classOf[MatcherApiRoute]
)

lazy val matcher: ActorRef = actorSystem.actorOf(MatcherActor.props(orderHistory, stateReader, wallet, utx, allChannels,
Expand Down
4 changes: 1 addition & 3 deletions src/main/scala/scorex/api/http/CompositeHttpService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import akka.stream.ActorMaterializer
import com.wavesplatform.settings.RestAPISettings
import scorex.api.http.swagger.SwaggerDocService

import scala.reflect.runtime.universe.Type

case class CompositeHttpService(system: ActorSystem, apiTypes: Seq[Type], routes: Seq[ApiRoute], settings: RestAPISettings) {
case class CompositeHttpService(system: ActorSystem, apiTypes: Set[Class[_]], routes: Seq[ApiRoute], settings: RestAPISettings) {

val swaggerService = new SwaggerDocService(system, ActorMaterializer()(system), apiTypes, settings)

Expand Down
16 changes: 9 additions & 7 deletions src/main/scala/scorex/api/http/swagger/SwaggerDocService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package scorex.api.http.swagger
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.github.swagger.akka.model.{Info, License}
import com.github.swagger.akka.{HasActorSystem, SwaggerHttpService}
import com.github.swagger.akka.SwaggerHttpService
import com.wavesplatform.Version
import com.wavesplatform.settings.RestAPISettings
import io.swagger.models.Swagger
import io.swagger.models.{Swagger, Scheme}

import scala.reflect.runtime.universe.Type

class SwaggerDocService(val actorSystem: ActorSystem, val materializer: ActorMaterializer, val apiTypes: Seq[Type], settings: RestAPISettings)
extends SwaggerHttpService with HasActorSystem {
class SwaggerDocService(val actorSystem: ActorSystem, val materializer: ActorMaterializer, val apiClasses: Set[Class[_]], settings: RestAPISettings)
extends SwaggerHttpService {

override val host: String = settings.bindAddress + ":" + settings.port
override val info: Info = Info("The Web Interface to the VSYS Full Node API",
Expand All @@ -23,5 +21,9 @@ class SwaggerDocService(val actorSystem: ActorSystem, val materializer: ActorMat
)

//Let swagger-ui determine the host and port
override val swaggerConfig: Swagger = new Swagger().basePath(prependSlashIfNecessary(basePath)).info(info).scheme(scheme)
override val swaggerConfig: Swagger = new Swagger()
.basePath(SwaggerHttpService.prependSlashIfNecessary(basePath))
.info(info)
.scheme(Scheme.HTTP)
.scheme(Scheme.HTTPS)
}
4 changes: 2 additions & 2 deletions src/main/scala/vsys/api/http/database/DbApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ case class DbApiRoute (settings: RestAPISettings, wallet: Wallet, utx: UtxPool,
@Path("/get/{nameSpace}/{dbKey}")
@ApiOperation(value = "get", notes = "Get db entry", httpMethod = "GET")
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "nameSpace", value = "Address", required = true, dataType = "String", paramType = "path"),
new ApiImplicitParam(name = "dbKey", value = "dbKey", required = true, dataType = "String", paramType = "path")
new ApiImplicitParam(name = "nameSpace", value = "Address", required = true, dataType = "string", paramType = "path"),
new ApiImplicitParam(name = "dbKey", value = "dbKey", required = true, dataType = "string", paramType = "path")
))
def getKV: Route = {
(path("get" / Segment / Segment) & get) { case (addr, dbKey) => {
Expand Down

0 comments on commit b8b3857

Please sign in to comment.