Live data from Hacker News

OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

github.com

61–70 of 73 posts

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#61
post #41

I was very excited about this project when I first encountered it as it seemed to be the best centralized community-driven way to generate code for multiple languages and supporting v3. The more time I spent with it the more disappointed I became. The reason why you are forced to write Java and write your own generator alongside the rest of the project is unclear to me. Extending the mustache templates is a pain (and…

Fellow "wrote my own generator" person here (I built the codegen system Stripe uses to generate their API client libraries). Sounds like you've got a pretty neat system too, hadn't thought of some of these approaches.

We had a similar story – after looking at the OpenAPI Generator and other options, we ended up making our own in JS from the ground up, more or less (it used the internals of prettier to generate pretty code, especially example snippets for docs, across languages).

I'm now starting a company (https://stainlessapi.com, mentioned by OP elsewhere on this thread) to solve this problem more generally. If you ever get tired of maintaining this system (which may not happen, it does sound fun/interesting) or want broader language support, and are open to a commercial solution, drop me a line: alex at stainlessapi.com

(open invite of course – and also always happy to just chat codegen things, it's a neat little niche)

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#62
post #10

I'm also curious about the reverse direction -- can I generate an openAPI spec from my typescript Api? I'd rather write code than schemas.

This is something we hope to build relatively soon at Stainless, inspired by Stripe's in-house Ruby API DSL. I think what you're asking for is the right approach.

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#63
post #30

We used this to generate api functions for our react application and then discovered and switched to Orval. It generates react query functions instead of „normal“ axios functions. Also it has support to generate a complete api mock with msw + faker.js - really nice.

This looks cool. Previously I was only aware of this blog post regarding React Query hooks from OpenAPI schemas: https://xata.io/blog/openapi-typesafe-react-query-hooks I take it that you’re happy with Orval. What are the biggest downsides?

The downside is it's pretty hard to maintain (the implementation is primitive string manipulation).

Another cool tool I found is `rapini` but sadly it has no MSW support.

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#64
post #51

Also check out Smithy from AWS ( https://github.com/awslabs/smithy ), the code it generates is much better. It's influenced by the new AWS SDKs so it has generator support for Rust.

Does smithy support OpenAPI? Doesn't seem like it does (found a reference to smithy -> openAPI support, but not the reverse).

I looked at Smithy further and it seems interesting but nascent. For example, all client code generators are in "early development": https://awslabs.github.io/smithy/2.0/implementations.html#cl...

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#65
post #29

Disclosure: I'm a contributor to the project. OpenAPI Spec and auto-generated API clients are very useful when multiple languages need to be supported, like when running a developer program. I've worked at companies that both use OpenAPI Generator for official clients and ones that wrote our own tools for API client SDK generation (with different design philosophy). I've used a number of generators myself to compare…

Hi!

First, thanks for this. It's a lot of work to support OSS and I appreciate the effort of you and the team.

Second, is there any way for new users to determine the maturity of each of the (many) generators available? I haven't seen it in the documentation or the github repo, but maybe I missed it?

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#66

Earlier quoted context omitted.

I prefer graphql because of this. It's a huge pain to maintain open API files and the generators are of varying quality supporting different specs. They also handle some parts differently in the output. Which generator have you used for typescript? There are 4 of them and all of them have different issues. I find the axios one the most stable but keen to know. How do you also handle refreshing token, incepting reques…

It shouldn’t be a pain to maintain OpenAPI files. The same code you write to validate your request/response should automatically generate the OpenAPI see my comment here: https://news.ycombinator.com/item?id=33221395

> The same code you write to validate your request/response should automatically generate the OpenAPI see my comment here

Or even better the opposite: I have a mini-framework [0] which does the validation and routing based on an OpenAPI spec, so the devs can focus on writing the business logic.

[0] https://pyapi-server.readthedocs.io

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#67
post #64
post #51

Earlier quoted context omitted.

Does smithy support OpenAPI? Doesn't seem like it does (found a reference to smithy -> openAPI support, but not the reverse).

I looked at Smithy further and it seems interesting but nascent. For example, all client code generators are in "early development": https://awslabs.github.io/smithy/2.0/implementations.html#cl...

It's actually used for the new AWS SDKs but yeah fairly new.

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#68
post #41

I was very excited about this project when I first encountered it as it seemed to be the best centralized community-driven way to generate code for multiple languages and supporting v3. The more time I spent with it the more disappointed I became. The reason why you are forced to write Java and write your own generator alongside the rest of the project is unclear to me. Extending the mustache templates is a pain (and…

Shameless plug for my conference talk on why I prefer a "compiler" approach vs a "template" approach to API library generation https://www.youtube.com/watch?v=mgRreyw-Nlg

Based on experiences with the same generator at Stripe that Alex (founder of stainlessapi.com) built.

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#69

Disclosure: I'm a cofounder of this startup We've been building client sdks as a service at Speakeasy ( https://www.speakeasyapi.dev/ ). API developer experience today in REST struggles because the openapi generators are buggy and generate machine-readable stubs rather than ergonomic SDKs. We ended up building a new generator from ground up focused on ensuring we could capture idiomatic features specific to each lang…

Great to see other engineers focusing on this space. I’ve spent a good chunk of my career writing in-house clients for various business critical APIs and have always had a giggle that our self-made ones were often far nicer to use than anything on the market but was always disappointed that due to a variety of corporate constraints they will never see the light of day. I can see a big benefit to bespoke hand-rolled c…

Thanks ! let us know if you'd want to try it out, happy to give you early access or generate a few SDKs for you.

Re: OpenAPI Generator allows generation of API client libraries from OpenAPI Specs

#70
post #41

I was very excited about this project when I first encountered it as it seemed to be the best centralized community-driven way to generate code for multiple languages and supporting v3. The more time I spent with it the more disappointed I became. The reason why you are forced to write Java and write your own generator alongside the rest of the project is unclear to me. Extending the mustache templates is a pain (and…

Shameless plug for my conference talk on why I prefer a "compiler" approach vs a "template" approach to API library generation https://www.youtube.com/watch?v=mgRreyw-Nlg Based on experiences with the same generator at Stripe that Alex (founder of stainlessapi.com) built.

They are 8 months old and have “strong revenues”. How do you do that? Seems like magic. I wish I were so talented.
Post reply on HN