Git Product home page Git Product logo

Comments (9)

pjfanning avatar pjfanning commented on June 15, 2024

https://github.com/pjfanning/swagger-akka-http-sample/blob/master/src/main/scala/com/example/akka/swagger/SwaggerDocService.scala doesn't seem overly complicated to me.

from swagger-akka-http.

manonthegithub avatar manonthegithub commented on June 15, 2024

As minimun it is redundant using scala.reflect where it is just not needed, no real difference but redundant conversions inside SwaggerHttpService:

object SwaggerDocService extends SwaggerHttpService {
  //similar but with classes
  override val apiTypes = Seq(classOf[AddService], classOf[HelloService])
  override val host = "localhost:12345"
  override val info = Info(version = "1.0")
  override val externalDocs = Some(new ExternalDocs("Core Docs", "http://acme.com/docs"))
  override val securitySchemeDefinitions = Map("basicAuth" -> new BasicAuthDefinition())
}

Additionally, in my case it doesnt work because I determine concrete type at runtime. I have a bunch of services and just registering them in SwaggerHttpService to be scanned and showed and it is much more convenient to use simple Class instead of searching Type when I register services at runtime, i.e. I do not know concrete list of services in advance to hardcode them.

from swagger-akka-http.

manonthegithub avatar manonthegithub commented on June 15, 2024
def toJavaTypeSet(apiTypes: Seq[Type]): Set[Class[_]] = {
    apiTypes.map(t => getClassForType(t)).toSet
  }

  private lazy val mirror = scala.reflect.runtime.universe.runtimeMirror(getClass.getClassLoader)

  def getClassForType(t: Type): Class[_] = {
    mirror.runtimeClass(t.typeSymbol.asClass)
  }

Is this really needed in SwaggerHttpService object?

from swagger-akka-http.

pjfanning avatar pjfanning commented on June 15, 2024

If you are blocked, could you copy the SwaggerHttpService code into your own code base and modify it for your own usage?
I will look at changing from types to classes but it could take me a while to get back to it.

from swagger-akka-http.

manonthegithub avatar manonthegithub commented on June 15, 2024

yeah, thanks, I can possibly create PR tomorrow, if you are very busy).

from swagger-akka-http.

pjfanning avatar pjfanning commented on June 15, 2024

How about adding a new val apiClasses: Seq[Class[_]] and merging the the 2 Seqs? This retains backward compatible support for apiTypes but allows users to use apiClasses instead (or as well).

from swagger-akka-http.

manonthegithub avatar manonthegithub commented on June 15, 2024

you broke compat since 0.10.0-SNAPSHOT so now master branch is not compatible with previous versions, so I guess it can be now split to two branches, old branch can remain compatible and new one I guess can be refactored with breaking it. What do you think about splitting?

from swagger-akka-http.

pjfanning avatar pjfanning commented on June 15, 2024

I like the scala type support and use it in my projects.

from swagger-akka-http.

pjfanning avatar pjfanning commented on June 15, 2024

Merged Pull Request

from swagger-akka-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.