ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
Vexatos_ has joined #crystal-lang
Flipez6 has joined #crystal-lang
brw7 has joined #crystal-lang
brw has quit [Read error: Connection reset by peer]
brw7 is now known as brw
Flipez has quit [Read error: Connection reset by peer]
Flipez6 is now known as Flipez
wolfshappen has quit [Read error: Connection reset by peer]
Vexatos has quit [Ping timeout: 256 seconds]
wolfshappen has joined #crystal-lang
ur5us has quit [Ping timeout: 256 seconds]
renich has quit [Quit: Leaving]
ur5us has joined #crystal-lang
void09 has quit [Ping timeout: 256 seconds]
void09 has joined #crystal-lang
ur5us has quit [Ping timeout: 268 seconds]
renich has joined #crystal-lang
ur5us has joined #crystal-lang
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ua__ has quit [Ping timeout: 260 seconds]
hightower4 has quit [Ping timeout: 260 seconds]
Flipez has quit [Changing host]
Flipez has joined #crystal-lang
jmdaemon has quit [Ping timeout: 248 seconds]
<FromGitter> <moe:busyloop.net> is there any way to get at the return type that crystal magically determines for a method during compilation when none is explicitly specified?
<FromGitter> <moe:busyloop.net> https://carc.in/#/r/czt0
<FromGitter> <moe:busyloop.net> i assume probably not :/
renich has quit [Remote host closed the connection]
renich has joined #crystal-lang
ur5us has quit [Ping timeout: 268 seconds]
Guest38 has joined #crystal-lang
<Guest38> Hey folks. If someone has a wikipedia account they could modify the page for Rust to mention Crystal as well. Seems pretty fitting among the listed languages in this sentence: "... commented on Rust's chances of becoming a competitor to C++ and to the other up-and-coming languages D, Go, and Nim (then Nimrod)"
renich has quit [Remote host closed the connection]
renich has joined #crystal-lang
<jhass[m]> You don't need an account to edit wikipedia, https://en.wikipedia.org/w/index.php?title=Rust_(programming_language)&action=edit
Guest38 has quit [Quit: Client closed]
wolfshappen has quit [Quit: later]
wolfshappen has joined #crystal-lang
ua_ has joined #crystal-lang
renich has quit [Remote host closed the connection]
renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> @moe:busyloop.net no, because it could probably change? If possible this is why its just easier to add a return type
<FromGitter> <HertzDevil> the def is separately instantiated for each set of argument types, so there isn't "an" inferred return type of the def
Welog has joined #crystal-lang
nq has quit [Quit: Leaving]
<FromGitter> <moe:busyloop.net> hmm makes sense. guess what i'd like is a way to inspect all the def's that are generated. ⏎ but i see why that isn't exactly feasible.
<FromGitter> <moe:busyloop.net> yeh, sometimes i'd just like to act on what the user actually returned w/o forcing them to explicitly declare it. in this case for generating the `responses` portion of swagger-docs based on what types an endpoint actually returns. forcing the user to be explicit can be annoying when it comes to nested and nilable types.
<FromGitter> <Blacksmoke16> in this case shouldnt an endpoint return essentially the same thing everytime?
<FromGitter> <Blacksmoke16> not like it could return a big union of things really?
<FromGitter> <moe:busyloop.net> well, in principle, yes. hmm, maybe i'm indeed making it too complicated. ⏎ i'll see how far i can get by forcing that def to be explicit.
<FromGitter> <Blacksmoke16> only exception is error responses, but if you raise them, they technically wouldnt be returned and you could handle that elsewhere
<FromGitter> <moe:busyloop.net> yeh, those i already got covered. in the renderer for an exception type you can declare whether it should automatically be injected into the swagger docs for all endpoints (useful for all the base-exceptions that can happen on any endpoint). and endpoints can declare the additional exceptions that they may throw (no way to discover them otherwise).
<FromGitter> <moe:busyloop.net> actually happy with how that part looks. thought that would be the harder one, but turns out the return types is actually more tricky as it fans out into return-type(s) -> renderer -> content-types.
<FromGitter> <moe:busyloop.net> getting that stuff to work at runtime was surprisingly easy (yay for crystal!). now discovering it *before* runtime to build those swagger docs. uff.
<FromGitter> <Blacksmoke16> i just made them required in athena, for diff reasons but the point is the same
<FromGitter> <Blacksmoke16> not *super* familiar with swagger, but i know they have a concept of models of which you'd use to represent the response yea? then from there is prob a way to show how they are rendered given various content types?
<FromGitter> <Blacksmoke16> i.e. the core type of the response doesnt change, just its representation
<FromGitter> <Blacksmoke16> serialized representation that is
<FromGitter> <moe:busyloop.net> ha, yea, you're pointing right at the hard part. ⏎ at first i had the models generate their swagger-schema. ⏎ ⏎ but then i realized, endpoints often only return a partial view of a model ⏎ (i.e. you don't want to include the password-field with users and don't want ... [https://gitter.im/crystal-lang/crystal?at=624c66049a09ab24f3dad3b8]
<FromGitter> <Blacksmoke16> prob a good idea to have a separate object used to represent payload/responses versus assuming that is going to match the DB model 1:1
<FromGitter> <Blacksmoke16> crystal stdlib and some shards have the ability to like exclude serializing the password on serialize but accept it on deserialize, but DTO would be a more robust way to go about that imo
<FromGitter> <Blacksmoke16> esp for more complex models so that the structure of the request doesnt need to be tightly coupled to the db schema
<FromGitter> <moe:busyloop.net> yea, rails has ActiveModelSerializer for this. guess i may just want too much ("just return whatever you want, we'll render & auto-doc it"). ⏎ works fine up to the point of auto-doc'ing & validating the input parameters. but the return value, that's really a tough cookie.
<FromGitter> <Blacksmoke16> ultimately you'd need to define what those validations are *somewhere*
<FromGitter> <Blacksmoke16> using a DTO for that would get you that + the structure of the request
<FromGitter> <Blacksmoke16> and have another for the response that describes the response
<FromGitter> <moe:busyloop.net> yup. i'll dig more into it in the coming days.
<FromGitter> <Blacksmoke16> could use the validation component for that ;)
<FromGitter> <Blacksmoke16> but sounds good 👍
wolfshappen has quit [Read error: Connection reset by peer]
jmdaemon has joined #crystal-lang
jmdaemon has quit [Quit: ZNC 1.8.2 - https://znc.in]
jmdaemon has joined #crystal-lang
wolfshappen has joined #crystal-lang
ua_ has quit [Read error: Connection reset by peer]
ua_ has joined #crystal-lang
mookie has joined #crystal-lang
ua_ has quit [Ping timeout: 268 seconds]
ua__ has joined #crystal-lang
straight-shoota has quit [Quit: ZNC 1.8.2 - https://znc.in]
straight-shoota has joined #crystal-lang
ur5us has joined #crystal-lang
renich has quit [Remote host closed the connection]
renich has joined #crystal-lang
renich has quit [Remote host closed the connection]
renich has joined #crystal-lang