These are chat archives for zalando/play-swagger

17th
Jun 2016
slavaschmidt
@slavaschmidt
Jun 17 2016 04:46
@reactormonk for optional, wrap your parameter as an Opt
for ints, you need to use appropriate parameter type... i mean, the query parameter is string anyways
for case classes i didn't get it
slavaschmidt
@slavaschmidt
Jun 17 2016 05:23
for jackson either :)
Simon Hafner
@reactormonk
Jun 17 2016 09:01
slavaschmidt, the issue is that for body parsing, jackson generates ints, which can't be cast into doubles, so I figured using a parser that doesn't rely on reflection would be the right way to go.
slavaschmidt
@slavaschmidt
Jun 17 2016 12:18

@reactormonk wait a second... this snippet

    put:
      description: This API endpoint can be used to query something updating underlying cache if needed
      parameters:
      - name: max_age
        in: body
        description: Max age in millisecond
        schema:
          type: integer
          format: int32
          minimum: 0
        required: true

works as expected for types integer with int32 and int64 format or with default one and number with float or double format and with default one as well

Simon Hafner
@reactormonk
Jun 17 2016 12:19
The issue is that I specify Dbl in the backend (apib only knows "number" IIRC), and when I get an Integer, it tries to cast that to a double
slavaschmidt
@slavaschmidt
Jun 17 2016 12:21
so you cannot define double with the apib ?
Simon Hafner
@reactormonk
Jun 17 2016 12:21
I interpret "number" as double, but jackson can't deal with that when passed in something that looks like an integer.
Any other JSON parser wouldn't worry too much and just give me a double, but because you gotta do casting, it can't handle the JsonNumber -> Double conversion.
slavaschmidt
@slavaschmidt
Jun 17 2016 12:24
if i specify the body type as a double, the generated controller has a parameter of type double... a can send a body with soma decimal value without problems
Simon Hafner
@reactormonk
Jun 17 2016 12:24
Try without decimal, e.g. 3
slavaschmidt
@slavaschmidt
Jun 17 2016 12:25
sure, no problems with that
Simon Hafner
@reactormonk
Jun 17 2016 12:25
I'm getting a classcastexception here.
slavaschmidt
@slavaschmidt
Jun 17 2016 12:25
strange
o
Simon Hafner
@reactormonk
Jun 17 2016 12:26
Using it in a body, json, parsed by jackson.
... into a case class.
slavaschmidt
@slavaschmidt
Jun 17 2016 12:26
ah, this way
give me a second to try
ok, now i see
Simon Hafner
@reactormonk
Jun 17 2016 12:34
A reasonable idea to parse via play.libs.json ?
slavaschmidt
@slavaschmidt
Jun 17 2016 12:36
this will require to generate parsers for all classes
Simon Hafner
@reactormonk
Jun 17 2016 12:36
Hm, I might hack to use argonaut-shapeless then
slavaschmidt
@slavaschmidt
Jun 17 2016 12:37
actually, i think that it won't be possible to solve this problem with swagger
and it's clearly a problem
so may be explicit parsers aren't bad idea
I'm just not sure about my timelines
Simon Hafner
@reactormonk
Jun 17 2016 12:38
I'm wiring my own controllers_base template anyway, I'll just hack it in there.
slavaschmidt
@slavaschmidt
Jun 17 2016 12:38
:smile: so you basically have your own plugin already
what do you do differently in the controller_base ?
Simon Hafner
@reactormonk
Jun 17 2016 12:39
StackAction for our auth
legacy etc, didn't bother too much to implement that via apib
And injecting CacheApi in the controllers
slavaschmidt
@slavaschmidt
Jun 17 2016 12:40
ok
Simon Hafner
@reactormonk
Jun 17 2016 12:40
Also fetching the logged in user in controllers_base and I hacked controllers to accept that as an additional parameter
Wasn't fun to debug, but it works now.
slavaschmidt
@slavaschmidt
Jun 17 2016 12:40
the last one is on my TODO
:)
yep, debugging generated code is not very straightforward
Simon Hafner
@reactormonk
Jun 17 2016 12:42
Oh, it worked after it compiled.
Honestly, I'd try to reduce the amount of generated controller code and maybe go for some more functions externally, so it's easier to change for a user.
slavaschmidt
@slavaschmidt
Jun 17 2016 12:46
after working with the plugin for a while i slowly get the same feeling. there are two problems, absence of really good specification format and lack of time to specify all functions properly...
Simon Hafner
@reactormonk
Jun 17 2016 12:47
No need to generate parsers for all classes, from what I see, play got some macros for creating these json classes
... json type classes.
slavaschmidt
@slavaschmidt
Jun 17 2016 16:42
I wasn't aware about that, I'll take a look
Garvin
@garvinguan
Jun 17 2016 21:20
Hi guys I'm on play2.4, swagger-play2 1.5.2, I'm getting Error injecting constructor, java.lang.ArrayIndexOutOfBoundsException any idea what could be causing this? For now I'm going to strip what I've written and slowly rebuild it
Simon Hafner
@reactormonk
Jun 17 2016 21:21
My condolences working with Guice :-/