Fork me on GitHub
#yada
<
2016-06-29
>
malcolmsparks05:06:06

@tawus - are you giving it a path-info, e.g. if you resource is bound to /hello, you should try with a URI of /hello/foo so that /foo becomes the path-info

malcolmsparks05:06:51

Those fixes to edge have been pushed. Edge now contains a working yada phonebook example. No swagger yet.

tawus06:06:27

Ah that might be it. Thanks @malcolmsparks I will try it out.

malcolmsparks06:06:09

Swagger added to phonebook. So now the phonebook example, with Swagger UI, swagger metadata and tags, etc. has been migrated to Edge so you can see how to put a non-trivial Swagger-assisted API together

ilukinov09:06:15

Hello, trying to understand and use your yada lib, with no luck for now. Where can I find "Getting Started” guide?

ilukinov09:06:30

@dominicm: thanks, will try that

dominicm09:06:54

Edge is good to download for yada.

ilukinov09:06:19

Problem with edge for me: 1. It uses boot (121 lines of code in build.boot OMG), so I need to learn this tool to, although i just started to understand lein a little bit 2. Looking in to build.boot - 24 dependencies, only one is commented [weasel "0.7.0" :scope "test"] ;; Websocket Server -> my head exploding

stijn13:06:50

@malcolmsparks: I have a question on your article https://juxt.pro/blog/posts/course-notes-2.html

stijn13:06:19

I intend to create something similar, but om is not going to be the client (yet)

stijn13:06:44

I just like to send edn over the wire to describe the query

stijn13:06:41

Would it still be a good idea to use om/parser in that case? Is there any documentation on the format of the data that om is sending back and forth to a remote?

malcolmsparks13:06:09

Yes. The Om Next query syntax is really a general 'pull' syntax. It's not too tightlt coupled to Om Next.

stijn13:06:35

this is the thing, the db is datomic

stijn13:06:04

but these are mobile apps doing the querying, and we're not using om next

stijn13:06:23

oh, ok in om.next.impl/parser.cljc there is a syntax for query expressions

stijn13:06:45

nice article btw, you can't find that much info on the topic yet

stijn14:06:15

why is om using transit instead of edn? performance?

griff14:06:25

What is the official way of adding support for my own data type to yada? There are the multimethods yada.body/render-map, render-seq and render-error for producing and yada.request-body/process-request-body for consuming but are they considered part of the public API?

griff14:06:47

By data type i mean mime type

imre14:06:44

when I needed to add support for transit I used those

imre14:06:52

they seemed to be public enough

malcolmsparks14:06:43

@stijn: yeah, transit is way faster than edn. Thanks to @imre yada has good transit support.

griff14:06:50

Well then I have the problem that default error rendering ignores :produces on the resource and is hardcoded to only support those listed in yada.handler/error-representations so I am forced to add a wildcard :responses key to circumvent this and force content-negotiation to accept my mime type for errors

griff14:06:16

Wouldn’t be more logical that if a resources declares that it produces a mime type and that mime type is implemented for render-error that mime type is at least supported in content negotiation for errors?

imre14:06:59

I do remember render-error being a little strange when I worked on transit

imre14:06:22

but as I didn't really need it I wasn't paying too much attention

malcolmsparks14:06:45

@griff. What if you only produce image/gif. What's the error then? A funny cat gif?

malcolmsparks14:06:19

I know that may sound like a cool feature

griff14:06:23

Well if render-error is not implemented for image/gif i expect and empty response

malcolmsparks14:06:52

What is the client also accepts text/plain?

griff14:06:25

Well yes the priority is a bit tricky

malcolmsparks14:06:39

I haven't thought about errors too hard, there's scope to change things. I'd like the error stuff to improve

griff14:06:37

What happens if default error-representations was yada.handler/error-representations and :produces from the resource?

malcolmsparks14:06:49

If a client sends Accept: image/gif, text/plain;q=0.1 then the error should be in text/plain - I don't see why not

malcolmsparks14:06:00

When I last gave this area some thought I concluded that the only thing to do was to renegotiate the content type - that doesn't require any network hops, just taking the original Accept header and a new set of possible representations

peterwestmacott20:06:10

hi, just having exactly the same problem as @ilukinov, does anyone know what we're missing?

peterwestmacott20:06:47

"Cannot turn resource-model into resource"

malcolmsparks20:06:42

@peterwestmacott: That is yada saying that the resource model (clojure map) is invalid according to the schema. There is a large defensive schema to ensure the resource is valid

malcolmsparks21:06:57

@ilukinov: the manual is getting overhauled. The getting started chapter is better. The install chapter predates edge and is really targetted at seasoned Clojure users. Things are improving but slowly, yada is a big project

ijbriscoe21:06:52

Hi @malcolmsparks Running the latest Edge, trying out the Swagger stuff. Not clear what I should browse to in order to see the API defined in the application. If I browse to http://localhost:3000/swagger/ I get the Swagger Petstore API!

malcolmsparks21:06:22

@ijbriscoe: go to http://localhost:3000/ - don't you get a page with links you can click on?

malcolmsparks21:06:40

the reason you get the Swagger Petstore API is that's the default if you don't give a url query parameter.

malcolmsparks21:06:01

the links in the index.html page do givea query parameter to the swagger ui though

ijbriscoe21:06:47

I do see the links. Thanks. Still figuring out what yada's Swagger implementation gives you, and what you need to do yourself... I'll look at that page to see how it's generated

malcolmsparks21:06:52

@ilukinov: I sympathise with your frustration. Those 121 lines of boot are doing a lot - there's both dev and advanced cljs compilation, sass css compilation, a browser repl, stuart sierra workflow reloaded, an nrepl server, all the figwheel-like stuff adzerk gives you, automatic reloads...

ijbriscoe21:06:47

Is it right that the swaggered function should provide a route that redirects to the UI, with the correct query parameter? I got very close to getting that working last night...

malcolmsparks21:06:52

the point I'm making is that with Leiningen, all that black magic (and it really is magic), is hidden away from you - boot is just a timepiece with a translucent cover rather than an opaque one - it's taken us months to get everything to work (and it probably has some kinks left)

malcolmsparks21:06:41

@ijbriscoe: it's confusing - there are 2 things you need to keep separate in your mind - there's the swagger.json generation, and the Swagger UI itself.

malcolmsparks21:06:56

The swagger UI is built in to edge (and yada actually), it's convenient to do so

ijbriscoe21:06:35

Yes - I think I've got the separation now - last night I was able to use swagger/swagger-spec to generate the json

malcolmsparks21:06:36

The swagger.json generation piece is separate, it takes you bidi routes, containing your yada resources, does a tree walk over the whole thing and ends up with a swagger.json (you can get swagger.edn too actually)

malcolmsparks21:06:52

the points of edge is to show you how it's all done.

ijbriscoe21:06:06

I'm just struggling with the very last bit of integration, tying the json to the UI

ijbriscoe21:06:30

I'll look at that index... I don't mind generating the link and doing a redirect if necessary

malcolmsparks21:06:40

bear in mind that the swagger.json generation is (merely) a tree-walk, compare that with the hoops that compojure-api has to jump through to generate you the same document

ijbriscoe21:06:43

but if it's provided anywhere in the API, I'd prefer to do that

malcolmsparks21:06:10

1. first thing is to get the swagger UI up (even with the petstore) -- that should be http://localhost:3000

ijbriscoe21:06:13

Agreed! There's so much to like in the yada + bidi combo

malcolmsparks21:06:17

Now you take the absolute URL of (2) and give it as a url query parameter to (1)

ijbriscoe21:06:01

OK - so I do understand it. Presumably I can compose that link using Bidi, if I tag the right resources?

malcolmsparks21:06:34

yes, that's how edge does it - look in resources/templates/index.html - you'll see we use selmer {% %} tags - there's a special one that uses {% url ... %} and it uses bidi to generate the url to X, where X is tagged with edge.resources/X - there's not that much code to it

malcolmsparks21:06:47

The point of edge is to show how it's all put together,

ijbriscoe21:06:28

Great - I'll get back to edge and take a good look.

malcolmsparks21:06:28

Without Edge it's been hard to explain to folks how to get the whole swagger thing working - and obviously the swagger UI has lots of its own js and images and css and stuff too

malcolmsparks21:06:07

I've just pushed some more commits to Edge that tidy up the code and begin to add some comments - soon enough it will all be fully commented

malcolmsparks21:06:29

But the build.boot thing is going to remain cryptic - it's really just to get the whole figwheel dev experience up and running - we're trying to show how yada, bidi and aero work together (and soon, skip too), rather than trying to show how boot works, so please just accept that the build.boot is crazy and your brain will explode if you try to understand how it works

malcolmsparks21:06:42

(that's how I cope with it anyhow!)

malcolmsparks21:06:22

@peterwestmacott: if you paste your resource-model and schema error I'll be able to explain what you've done wrong

martinklepsch21:06:12

what's skip? 🙂

malcolmsparks21:06:24

That's my clojutre talk :)

malcolmsparks21:06:39

If it's accepted

malcolmsparks21:06:45

Anybody going?

malcolmsparks21:06:42

@ijbriscoe: Also, having a single bidi/yada tree structure is a big deal - it's taken a long time - but it's not just to make swagger.json generation easier, the plan is much broader than that. Eventually they'll be lots of tools that can walk that tree and generate other formats and drive processes such as automating the creation of an API on Amazon's AWS API Gateway, so you might one day be able to develop your API in Clojure and 'deploy' it to a serverless infrastructure. There's also a chance that the same data will drive a clojurescript (nodejs) version of yada

ijbriscoe22:06:55

It's certainly got a lot of potential; like many Clojure libs - I speak as a experienced developer, but Clojure novice - it takes a bit of effort to understand, but so far, well worth it