Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 25 20:11
    scala-steward closed #630
  • Jan 25 20:11
    scala-steward commented #630
  • Jan 25 20:11
    scala-steward opened #650
  • Jan 23 00:53
    scala-steward closed #648
  • Jan 23 00:53
    scala-steward commented #648
  • Jan 23 00:53
    scala-steward opened #649
  • Jan 20 04:13
    scala-steward closed #642
  • Jan 20 04:13
    scala-steward commented #642
  • Jan 20 04:13
    scala-steward opened #648
  • Jan 19 22:11
    scala-steward closed #645
  • Jan 19 22:11
    scala-steward commented #645
  • Jan 19 22:11
    scala-steward opened #647
  • Jan 14 01:33
    scala-steward closed #614
  • Jan 14 01:33
    scala-steward commented #614
  • Jan 14 01:33
    scala-steward opened #646
  • Jan 12 21:45
    scala-steward closed #632
  • Jan 12 21:45
    scala-steward commented #632
  • Jan 12 21:45
    scala-steward opened #645
  • Jan 12 09:32
    scala-steward opened #644
  • Jan 03 10:28
    martijnhoekstra opened #643
Yotam Hochman
@Yotamho
Hi, I started to use rho and see that when I create a RhoRoutes, I get a logger from it
is there any convenient way to use a different logger (scalalogging's one) but still using the variable name logger ?
Rafał Sumisławski
@RafalSumislawski

Hi @Yotamho
You cloud copy the source of RhoRoutes, and have your own version with the logger field removed. That's what I would do.

Among other options you can also create a block { } inside your class extending RhoRoutes. And while you cannot create a 'logger' field in the class, you can create a val logger in the block, which will shadow the logger field inherited from RhoRoutes. You would then have to put all your code using the logger inside that block. That would work as long as you don't plan having any public members in that class (you can't put public members in the block). It's a bit hacky :P

Kingsley Hendrickse
@kingsleyh
hi - for a List[Long] as the payload in a POST request - it's generating this yaml - which looks incorrect - any ideas on how to solve this?
 - in: "body"
        name: "body"
        description: "List«Long»"
        required: true
        schema:
          type: "array"
          items:
            title: "Long"
            $ref: "#/definitions/Long"
Gavin Bisesi
@Daenyth
that A+circumflex looks like mojibake
are you sure you're generating utf-8 yaml and viewing the file as utf-8
I think that specific character indicates your yaml file might actually be Latin-1 instead of utf-8
If not that, then the inverse
Or CP1252, which is almost the same as Latin-1
Kingsley Hendrickse
@kingsleyh
the items part seems wrong tho
in the doc it makes a list of empty object
I would have thought it should make items with: type: 'Integer', no ref as it's a primitive and then format: 'int64'
like this
  type: "array"
          items:
            type: "integer"
            format: "int64"
Gavin Bisesi
@Daenyth
Oh it's probably because List is a generic and therefore at runtime they get boxed
generics must take subtypes of Object (AnyRef), which primitives are not
Kingsley Hendrickse
@kingsleyh
I see
Gavin Bisesi
@Daenyth
This does feel like something the library should figure out
Kingsley Hendrickse
@kingsleyh
In my case it's quite common to have lists of int or long or string in the payload of POST and PUT requests
Gavin Bisesi
@Daenyth
I think it does get specialized, maybe? I'd open a ticket
Kingsley Hendrickse
@kingsleyh
many of the endpoints were designed way before I started looking at Rho and how to auto generate the docs
yeah - I'm not sure how frequently things get picked up here - maybe I should take a look and send a pull request
thanks for your help :)
Yasuhide Hoshiko
@hoshikon_gitlab
Hi, is there a way to add descriptions to request body or headers? I can't find any documentation nor examples..
Kingsley Hendrickse
@kingsleyh
@Daenyth do you know if it's possible to write the generated yaml / json to a file as well as serving it? Currently the served yaml inherits the authorisation so can't be accessed unless authorised but we want to maybe write it to file and serve it from a non authed endpoint.
jjcapper
@jjcapper
Hey all, quick (and potentially naive) question about using the API. After some digging as to why my swagger docs didn't cover any of the response types, I discovered that if I moved the response code (e.g. Ok(...)) into the body of new RhoRoutes[IO] { ... } then everything started working. So my next question is, how can we achieve this without requiring that everything be written in situ?
At the moment, my best guess is to pass new argument around everywhere (implicit responses: ResponseGeneratorInstances[IO]) and try and use this when declaring the routes? ... E.g. "Description of an endpoint" ** POST / "pathhere" ^ jsonOf[IO,MyType] |>> { (body: MyType) => myDef(body)(this) }
I feel like this can't possibly be the right way to go about it though
Kingsley Hendrickse
@kingsleyh
Ive just started using rho and i found that due to the way it works with implicits i have to put everyhing inside the new RhoRoutes - the only way i found as a workaround was to pass the rho routes into another class and import e.g. import rhoRoutes._ to get all the implicits
Nikita
@nikit-os
Hi all! I have POST endpoint with case classes for request and response. All fields in case classes in camelCase but circe configured to use snake_case. Rho generates definitions in camelCase. How to generate swagger.json with definitions in snake_case?
ziggystar
@ziggystar
Hi. I have an API using authorization on some end points. I'm trying to integrate rho for swagger generation. Above I found a message that confirmed that for generating swagger spec, there is some plumbing required for APIs with authorization (cannot use SwaggerMiddleware). But I have even more problems (at least I think so, because I do not fully grasp everything). My authorized routes are nested within Routers. I'm under the impression that the authorization rho meta information does not compose through Routers. At least this is not implemented. Can someone please comment on my thoughts? I can also provide some more details, if required.
Alexandr Solodkyi
@solo-rh
@jjcapper I solved it with next hack:
object Api extends ResponseGeneratorInstances[IO]
usage outside RhoRoutes:
Api.NotFound("response")
Adriani Furtado
@Adriani277
Hi All, could anyone point me in the right direction as to how I can specify the swagger format for a query param. I currently have a query parameter that I would like to be displayed as a UUID. I tried to have a look at the lib code but couldn't find any references to format
Adriani Furtado
@Adriani277
I guess the question would be; is it possible to define something similar to a Model for query params?
Alexandr Solodkyi
@solo-rh
@Adriani277 Can the query be anything other than a primitive value (int, string, double)?
Adriani Furtado
@Adriani277
Hi @solo-rh , the query will always be a String. I noticed that we dont support UUID format. I fount formats for int and so on but no uuid.
On another note. I have defined some query parameters and custom query parsers. Howver i noticed that the swagger docs dont show the error responses that can be returned as a result of those query parsers failing. Is there a way to enforce this?
Jarrod Young
@jarrodcodes
Hey there, having some trouble with Refined types. I saw that someone had posted an issue on it. They mentioned that adding their own StringParser solved their issues. I have done the same but cannot find a solution. My case class that used refined types doesn't have a successful definition in the Swagger UI.
Even after adding a custom StringParser.
Jarrod Young
@jarrodcodes
Nevermind I found the issue. Method paramSymToProp was throwing an exception that Refined types are not a class. A custom fieldSerializer fixed it.
JLofgren
@JLofgren
Hello! I am brand new to using rho. I have an existing http4s application that under certain error conditions returns status code 470 or 471. These are custom codes that have particular business meaning. I don't understand how to write the rho DSL that will allow custom response codes. It seems like the type structure of Result locks you into only the "common" status codes.
Jonas Natten
@jnatten
Hello smart people!
Could anyone explain to me how i can generalize my authentication response?
I wrote this, and used in in a route. It works, but the swagger field for the responses part is not generated at all.
def doOrAccessDenied(user: Option[UserInfo], w: => F[Result.BaseResult[F]])(
    implicit F: Monad[F],
): F[Result.BaseResult[F]] = {
  user match {
    case Some(user) if user.canWrite => w
    case Some(_)                     => Forbidden(Error.forbidden)
    case None                        => Unauthorized(Error.unauthorized)
  }
}
marmaladesky
@marmaladesky:matrix.org
[m]
@jnatten
Looks like BaseResult is the reason. Here is an example that works for me:
def withAuth[T >: F[FORBIDDEN[ErrorMessage]], A <: T](auth: UserDetails, f: UserDetails => A)(implicit c: Concurrent[F]): T = {
  if (isAllowed(auth)) {
    f(auth)
  } else {
    Forbidden(ErrorMessage("Some error message"))
  }
}
marmaladesky
@marmaladesky:matrix.org
[m]

Hi folks!
Could anybody please share an example to generate a classical Swagger file upload?

paths:
   /upload:
     post:
       summary: Uploads a file.
       consumes:
         - multipart/form-data
       parameters:
         - in: formData
           name: upfile
           type: file
           description: The file to upload.

I didn't notice this feature in the sources. Is it possible at all?
If not, could you please share your thoughts about how it "should be" implemented?