Live data from Hacker News

Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

github.com

51–60 of 76 posts

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#51
post #21

Earlier quoted context omitted.

http://thrift.apache.org/

I think that creates an API, then exposes it in numerous languages. This writes wrappers to existing APIs. Not the same thing. (Lots of code similarity under the hood, though.)

No, it actually does both - which is why I was so interested in it initially.

from the above link: "generates code to be used to easily build RPC clients and servers"

TBF, I haven't used it as a developer, but I did contract work with a company that had invested in it heavily. From what I saw of their workflow, it ended up being a pretty nice bootstrap tool and little more.

edit: Oh, I see what you're saying. Yes, you're correct - thrift does not wrap existing APIs.

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#52
post #44

Earlier quoted context omitted.

I'm confused by this comment. What would the tests test? My thinking is that, if trusted to output a library that matches the API spec, there is no need to test that API. However, that does require that Alpaca is well-tested enough to be trusted - would you be happy with tests in Alpaca itself, or should it generate tests too?

I guess it depends on whether you view Alpaca as (a) "it's a starting point for generating your API", or (b) "it's the authoritative source and the only way to generate your API". If you use it like (b) you don't need tests, but Alpaca does. If you use it like (a) Alpaca still needs tests, but the buck stops with you.

Ah, using it as a starting point, that you then want to test. That makes sense, thanks :)

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#53
I have to admit, this is very reminiscent of "Add Service Reference" in Visual Studio, a capability to which I have grown to despise over the years. The code was almost always incomprehensible. I cannot tell you how much I loath seeing the comment at the top of a file "This was generated by a tool".

Having said that, this tool does look interesting. I hope that a goal is to always make sure that the generated code is as readable, and maintainable, as possible. Also, as mentioned by others, adding generated tests to the generated client libraries is extremely important.

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#55

Am I right in thinking about this like a WSDL, but based on JSON?

It looks like a WSDL-like spec (although not as complete) with a code generator as well.

I wonder if we'll see JSON versions of DISCO and whatnot as well.

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#56

I have to admit, this is very reminiscent of "Add Service Reference" in Visual Studio, a capability to which I have grown to despise over the years. The code was almost always incomprehensible. I cannot tell you how much I loath seeing the comment at the top of a file "This was generated by a tool". Having said that, this tool does look interesting. I hope that a goal is to always make sure that the generated code is…

You can go through the generated code examples at https://github.com/alpaca-api.

I tried to make them a lot more readable. :)

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#57
post #6

Can we please stop calling Web Services APIs?

Why? what else do you call APIs?

Libraries and operating systems have APIs.

Web sites have Web Services using REST, XML-RPC, SOAP, whatever as communication protocol.

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#59

Earlier quoted context omitted.

Right, the format affords generic description documents from which to generate client code. This seems very similar in spirit to WSDL. No?

WSDL is not a method in itself for actually generating the client code, though. It's simply a (barely) machine readable description of the API from which clients decide how to deal with it. EDIT: Since I was down-voted for whatever reason, I'd like to rephrase. WSDL is a standardized language for defining web services. It's not a tool in itself for generating client code, and what I said was meant to point out that t…

You're being downvoted because this project is a generator program which, as input, takes a specification of the API in JSON format. This JSON specification is what is being compared to WSDL because they serve the same purpose: to define the endpoints, arguments, and return values for a given API.

Re: Show HN: Given an API, Generate client libraries in Node, Python, PHP, Ruby

#60
Well done!

Know what I think would be really neat? If it could be pointed at an instance of Swagger-UI, or use the same discoverUrl that Swagger-UI would use, and spit out the libraries from that.

If you're not familiar.. https://github.com/wordnik/swagger-ui

Post reply on HN