Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Otto Chrons
    @ochrons
    or by not using @ApiImplicitParam but defining it inline instead,
    def getProject(@ApiParam(name = "projectId", value = "Project identifier", required = true) @PathParam("projectId") projectId: String)
    perhaps that's the Correct way to do it
    PJ Fanning
    @pjfanning
    If the function takes params, then use the @ApiParam and if it doesn't, use @ApiImplicitParams.
    Otto Chrons
    @ochrons
    Got it. Thanks for the library, works well
    Hopefully the Jackson json structure is the same as generated by Circe I'm using
    Remko de Jong
    @aggenebbisj
    How can I change the model definition of a sealed trait (enum) to be entered as a String? I tried the @ApiModel annotation, but it does not seem to be picked up. In the swagger.json it is still listed with type: "object"
    Remko de Jong
    @aggenebbisj
    Basically I'm looking for a way to do custom mappings, is that possible?
    PJ Fanning
    @pjfanning
    Remko de Jong
    @aggenebbisj
    Thanks for the quick reply
    It was actually not a param but a property, but found a way in the mean time using ApiModelProperty on the class that uses the sealed trait.
    Remko de Jong
    @aggenebbisj
    Is it possible to use converters in swagger-akka-http as described in https://github.com/swagger-api/swagger-core/wiki/overriding-models?
    PJ Fanning
    @pjfanning
    https://github.com/swagger-api/swagger-scala-module is a model converter (as in wiki entry ^^^)
    Remko de Jong
    @aggenebbisj
    Yes, but I specifically want to override a complex scala structure with something like in:
    import com.wordnik.swagger.converter.{ ModelConverters, OverrideConverter }
    
    val jsonString = """
    {
      "id": "Date",
      "properties": {
        "value": {
          "required": true,
          "description": "Date in ISO-8601 format",
          "notes": "Add any notes you like here",
          "type": "string",
          "format": "date-time"
        }
      }
    }
    """
    val converter = new OverrideConverter
    converter.add("java.util.Date", jsonString)
    
    ModelConverters.addConverter(converter, true)
    I have a trait that is extended by a few case classes, each having some common properties and some different ones. In the JSON this structure is represented flat with a discriminator type
    Remko de Jong
    @aggenebbisj
    sealed trait Foo {
      def x: Option[BigDecimal]
      def y: Int
      def fooType: FooType
    }
    
    final case class Bar(_x: BigDecimal, y: Int) extends Foo {
      override def fooType = BAR
      override def x = Some(_x)
    }
    
    final case class Baz(y: Int) extends Foo {
      override def fooType = BAZ
      override def x = None
    }
    
    sealed abstract class FooType 
    case object BAR extends FooType
    case object BAZ extends FooType
    {
      "fooType": "BAR",
      "x": 1.234,
      "y": 3
    }
    So how would I achieve this?
    PJ Fanning
    @pjfanning
    Have you tried something likeExcluding fields with a Custom Model Converter (1.3.1 and greater) in the wiki doc you have posted ^^^?
    adding a ModelConverter - ModelConverters.addConverter(new CustomConverter, true)
    Remko de Jong
    @aggenebbisj
    Yes, that part is outdated, the API changed and it's not just about excluding some fields. So unfortunately I'm a bit stuck
    But for Akka Http I'm afraid my Swagger expertise is lacking too much to roll my own, hence the request for help :-)
    PJ Fanning
    @pjfanning
    The code at the bottom of the wiki is up to date (latest APIs - the com.wordnik parts at the top are completely out of date) - https://github.com/swagger-api/swagger-scala-module has a model converter that you could examine to see how one works
    Remko de Jong
    @aggenebbisj
    I will give it a try
    Remko de Jong
    @aggenebbisj
    Would it be possible to update the swagger-akka-http-sample project with a simple sealed trait as one of the models? I've tried for a couple of days now, but just cannot seem to get it to work, even though unit tests in swagger-akka-http prove that it should. For me it keeps returning an empty object in the definition
    Even if I dumb it down to
    sealed trait Foo { val x: Int }
    case class Bar(x: Int) extends Foo
    From swagger:
    Foo: {
      type: "object"
    }
    PJ Fanning
    @pjfanning
    the code for handling scala models is in https://github.com/swagger-api/swagger-scala-module
    the test cases revolve around case classes and the params defined as part of case class constructor, eg case class Bar(x: Int) - there are no tests for traits like trait Foo { val x: Int }
    PJ Fanning
    @pjfanning
    I added a failing test to a branch - pjfanning/swagger-scala-module@1760fae
    A quick (admittedly messy) workaround is to declare a case class FooModel(x: Int) extends Foo and use this in your swagger annotations
    Remko de Jong
    @aggenebbisj
    Thanks for helping

    A quick (admittedly messy) workaround is to declare a case class FooModel(x: Int) extends Foo and use this in your swagger annotations

    Yeah, I kind of want to stay away from this if possible

    Do you want me to create an issue for this?
    PJ Fanning
    @pjfanning
    @aggenebbisj if you raise an issue, could you raise in swagger-scala-module (as opposed to swagger-akka-http)?
    Remko de Jong
    @aggenebbisj
    swagger-api/swagger-scala-module#48
    @pjfanning ^^ there's the issue I logged
    Saheb Motiani
    @Saheb
    Not able to handle multiple parameter list. Is there a workaround?
      def createSource(
        @ApiParam(value = "Source to be created", required = true) source: Source
      )(implicit headers: Headers): Future[ToResponseMarshallable] =
    it just hangs. swagger.json generated for it.
    "parameters": [
    {
    "name": "sourceId",
    "in": "path",
    "description": "Id of Source",
    "required": true,
    "type": "string",
    "format": "uuid"
    },
    {
    "in": "body",
    "name": "body",
    "description": "Source to be updated",
    "required": true,
    "schema": {
    "$ref": "#/definitions/Source"
    }
    },
    {
    "in": "body",
    "name": "body",
    "required": false,
    "schema": {
    "$ref": "#/definitions/Headers"
    }
    }
    ]
    Francesco Usai
    @kekkooo

    Hello there,
    I am struggling to understand how to handle query parameters of enum type.
    let's suppose I have a

    object Country extends Enumeration {
    
      type Country = Value
    
      val Italy = Value(1, "IT")
      val UnitedKingdom = Value(2, "UK")
    }

    used for a queryString parameter called country and I would like to obtain this kind of documentation:

    "name": "country",
    "in": "query",
    "description": "user country",
    "required": true,
    "type": "string",
    ""enum": [
        "IT",
        "UK"]
    }

    how can I obtain this result using I tried different solutions with no luck, and I would not resolve to use @ApiImplicitParam with hardcoded allowableValues

    thanks

    PJ Fanning
    @pjfanning
    @kekkooo I just added an enum sample on a branch of my swagger-akka-http-sample - https://github.com/pjfanning/swagger-akka-http-sample/tree/enum-sample
    Yuriy Pitomets
    @Pitometsu
    hi there, need some help with swager-akka-http, is it proper place to ask, or it will be better to create an issue on github?
    Yuriy Pitomets
    @Pitometsu
    @pjfanning is there a possibility to annotate method with parameter of type like NecessaryData => Route?
    PJ Fanning
    @pjfanning
    swagger-akka-http is a thin wrapper over swagger-jaxrs and that latter library deals in classes, not functions - but, if the libs don't generate the swagger that you want, you can override the behaviour using swagger annotations
    Yuriy Pitomets
    @Pitometsu
    @pjfanning thank you, another question: is there any way to describe values of @ApiModel description of some Enumeration?
    PJ Fanning
    @pjfanning
    @Pitometsu see ^^^ April 01 comments - the sample has been modified to highlight OpenAPI 3 support but there is a branch for the older code (https://github.com/pjfanning/swagger-akka-http-sample/tree/swagger-1.5) - swagger-akka-http 1.0.0 and earlier has very basic support for scala enums - swagger-akka-http 2.0.0 does not - I prefer to use the swagger annotations for enums as they provide a mechanism to set the actual enum values
    Beezlebob
    @Beezlebob
    Hi, i'm having some issues with the conversion from Map[String, Any] to swagger-doc. It seems to translate it into:
      "type" : "object",
              "additionalProperties" : {
                "type" : "number"
              }
         }
    Harry Laoulakos
    @harrylaou
    image.png