These are chat archives for zalando/play-swagger

1st
Mar 2016
Simon Hafner
@reactormonk
Mar 01 2016 10:33
The logic in the transfromer joins multiple ParameterRef?
Simon Hafner
@reactormonk
Mar 01 2016 10:53
For a starting point, what would the model for https://gist.github.com/4bc7af356bdcb833111f look like?
slavaschmidt
@slavaschmidt
Mar 01 2016 11:25
how would it look like if converted to the normal JSON?
Simon Hafner
@reactormonk
Mar 01 2016 11:27
{ configSelection: { activeNotificationEmail: "foo@bar.com" } } where the activeNotificationEmail is optional.
slavaschmidt
@slavaschmidt
Mar 01 2016 11:41
in Scala this would be, right?
type ActiveNotificationEmail: Option[String]
case class ConfigSelection(configSelection: ActiveNotificationEmail)
not sure about default values
i think we don't have them yet
Simon Hafner
@reactormonk
Mar 01 2016 11:43
No, i ast.scala types.
slavaschmidt
@slavaschmidt
Mar 01 2016 11:45
sure
I just want to be sure that my understanding of what is expected as a scala result is correct
if it is, than the types would look like this
⌿paths⌿/⌿post⌿configSelection⌿activeNotificationEmail ->
    Opt(Str)
⌿paths⌿/⌿post⌿configSelection ->
    TypeDef(⌿paths⌿/⌿post⌿responses⌿200, Seq(Field(⌿paths⌿/⌿post⌿configSelection⌿activeNotificationEmail, Opt(Str))))
Simon Hafner
@reactormonk
Mar 01 2016 11:47
Yes, that looks good.
slavaschmidt
@slavaschmidt
Mar 01 2016 11:47
you could take a look for type structures for different specifications in /Users/slasch/work/workspaces/zalando/play-swagger/compiler/src/test/resources/expected_results/types
the path prefix would probably differ in your case, dependent upon where these types are used
the duplication of type is intended, it will be optimised later
Simon Hafner
@reactormonk
Mar 01 2016 11:49
and if I have named types (exists in apiary), what path should I use? any prefixes, aka ⌿paths⌿/Play?
slavaschmidt
@slavaschmidt
Mar 01 2016 11:50
in swagger it's "definitions" and we rely on this convention
like ⌿definitions⌿User
Simon Hafner
@reactormonk
Mar 01 2016 11:50
Thanks.
slavaschmidt
@slavaschmidt
Mar 01 2016 11:50
example in /Users/slasch/work/workspaces/zalando/play-swagger/compiler/src/test/resources/expected_results/types/full.petstore.api.yaml.types
sorry, not the full path of course :)
Simon Hafner
@reactormonk
Mar 01 2016 11:51
How do I use definitions in there? It's entirely valid to use them as an element in apiary.
do I have to resolve it?
slavaschmidt
@slavaschmidt
Mar 01 2016 11:52
sorry, don't understand the question
which is short for { configSelection: <something of type Config Selection> }
or rather long for.
slavaschmidt
@slavaschmidt
Mar 01 2016 11:53
yep, for this we have References
but you have to inline them
Simon Hafner
@reactormonk
Mar 01 2016 11:53
as in resolve?
slavaschmidt
@slavaschmidt
Mar 01 2016 11:53
if you want type optimisations to work correctly
sorry, what is a "resolve" ? :)
Simon Hafner
@reactormonk
Mar 01 2016 11:54
Btw, what's Opt? isn't that optional?
well, it's Option, but that should be close enough.
oh wait. You just said no defaults. Sorry.
slavaschmidt
@slavaschmidt
Mar 01 2016 11:55
Opt is a wrapper for types which are optional
defaults are allowed, but not on the type-level
they are used as a part of route definition
Simon Hafner
@reactormonk
Mar 01 2016 11:56
So I can't have TypeDef(⌿definitions⌿Foo, Seq(Field(⌿definitions⌿Foo⌿bar, TypeRef(⌿reference⌿)))) ?
Forgot a Bar after ⌿reference⌿
slavaschmidt
@slavaschmidt
Mar 01 2016 11:58
you can
but i'm not sure you won't get duplicate types with different names created from that
Simon Hafner
@reactormonk
Mar 01 2016 12:00
Aren't the names fully qualified?
slavaschmidt
@slavaschmidt
Mar 01 2016 12:01
yes, but you can have multiple different references pointing to multiple different types which are the in essence the same
you don't won't always want to have multiple different type aliases for Option[String] for example
Simon Hafner
@reactormonk
Mar 01 2016 12:02
I'd prefer it to be the same type in the end.
slavaschmidt
@slavaschmidt
Mar 01 2016 12:02
it will be if you inline it as well
Option is a bad example
Simon Hafner
@reactormonk
Mar 01 2016 12:03
So I need to have two passes? One to find all the definitions, and a second to parse the rest?
slavaschmidt
@slavaschmidt
Mar 01 2016 12:03
let's say you have a structure User(name: String, age: Int)
if they are defined only once, it's use a reference
if they are inlined twice, they will got different references pointing to them and accordingly different names
and you won't be able to mix them, even if they are in essence the same type
so if you want two equal structures to become a single scala type, you have to inline them
Simon Hafner
@reactormonk
Mar 01 2016 12:05
I'm interested in the first kind, references.
slavaschmidt
@slavaschmidt
Mar 01 2016 12:05
if you want them to be separate, you can use references
then inline them in type definition like in the example i posted in the chat
no, you don't need two passes
exactly the opposite
you just inline all the definitions during the first pass
Simon Hafner
@reactormonk
Mar 01 2016 12:08
What do you understand under "inline"? I understand that as "copy the full definition here".
slavaschmidt
@slavaschmidt
Mar 01 2016 12:10
yep
Simon Hafner
@reactormonk
Mar 01 2016 12:11
But then I'd need to collect the definitions first.
slavaschmidt
@slavaschmidt
Mar 01 2016 12:11
ah, ok, they are defined separately
in that case it might be safe to use references
i'm not sure, but you could try and we'll see how it will work
Simon Hafner
@reactormonk
Mar 01 2016 12:13
e.g. https://gist.github.com/4d51e1f8ce01db0fcbdb see id: "Data Set" - that could be used in another datastructure.
slavaschmidt
@slavaschmidt
Mar 01 2016 12:15
yep, i think it should be safe
Simon Hafner
@reactormonk
Mar 01 2016 12:15
long for DataSet(id: String, dataVersion: String, name: String) - how would I transfer that into a Reference? I see I can use it later with TypeRef(name), but how do I create it in the first place?
slavaschmidt
@slavaschmidt
Mar 01 2016 12:16
if it won't be this will be a bug with the type flattener, so i'll fix that
this can be any Reference, it does not related to the type structure
Simon Hafner
@reactormonk
Mar 01 2016 12:16
I guess it goes into ParameterLookupTable ?
Simon Hafner
@reactormonk
Mar 01 2016 12:22
What exactly is the DiscriminatorLookupTable? I suppose that's ued by the type unification?
How much of these tables do I have to populate myself?
slavaschmidt
@slavaschmidt
Mar 01 2016 12:34
please take a look at /play-swagger/compiler/src/main/scala/de/zalando/swagger/ModelConverter.scala
that's why you expected to provide
DiscriminatorLookupTable contains inheritance-related information
it links discriminator names to the root of the class hierarchy they define
Simon Hafner
@reactormonk
Mar 01 2016 12:47
Ok, thanks.
slavaschmidt
@slavaschmidt
Mar 01 2016 12:53
no problem
Simon Hafner
@reactormonk
Mar 01 2016 14:16
What should I translate enums to? /enum in typeConverter.scala doesn't give me any results.
slavaschmidt
@slavaschmidt
Mar 01 2016 14:58
enums are just instances of the type of this enum (f.e. String for enum of Strings) with enum validation rule defined on them
Simon Hafner
@reactormonk
Mar 01 2016 15:05
Any reason for the comma-separated list in the enum validation?
slavaschmidt
@slavaschmidt
Mar 01 2016 15:09
absence of better design at the time it was implemented :)
slavaschmidt
@slavaschmidt
Mar 01 2016 15:17
actually, in swagger this is an array of allowed values
Simon Hafner
@reactormonk
Mar 01 2016 15:38
Where exactly do I put in the validation in ast.scala?
ah, in the meta.
Simon Hafner
@reactormonk
Mar 01 2016 15:44
... or not. hm.
slavaschmidt
@slavaschmidt
Mar 01 2016 16:56
yep, in the meta