Analyzing the OpenAPI Tooling Ecosystem
modern-json-schema.com
modern-json-schema.com
One observation, is that I there are two trains of thought. Using OAD (Open API Descriptions) as a source of truth and generating code from there or treating OAD as an artifact that comes out of some other tools.
I personally see OpenAPI as kind of a glue that can allow different tooling to be able to speak the same language.
Overall I found the linked Moonwalk[1] document to be more interesting. But there is some interesting analysis to be found in this article as well.
[1] https://www.openapis.org/blog/2023/12/06/openapi-moonwalk-20...
I'm not sure the article really succeeds if that was the goal. I suspect that there might be some aspects of the discussion that are taking place that are missing from the article making it a little difficult for someone who wasn't in those discussions to connect the dots.
Don't get me wrong, I think the article had some useful pieces in it, I just think if that was the goal of the article it could possibly use some additional framing for people who don't have the full context.
With that said, I really appreciate transparency into the thought process!
It's always a struggle to figure out how much explanation to put in before people see something like "20 minute read" and just refuse to read it. (BTW I don't mind the critical feedback at all- I'm just glad you found something useful in it).
But keep in mind that _we_ haven't answered "how do we actually make it a real spec?" either! This is a snapshot of our efforts at this particular moment. Also, there's a reason that this is "part one in a series" :-)
You can also record a blank video on your phone for 20 minutes and call that a movie. Would anyone watch it?
You can also build a house in days. Would it crack? Is it maintainable? What happens later? Who knows.
I think it's a fair attitude if your only goal is to make money, but it completely misses "why" you should build something... if you truly care about a problem you wouldn't haphazard it anyway.
Short term, yes. But it's a bit short sighted as most of the AI code I have seen has security and scalability issues that long term have potential to blow up in your face costing even more money.
Granted that can usually be fixed by better prompts. But to right those prompts requires the person doing the "prompt engineering" (rolls eyes) to actually have a working knowledge of a lot of areas such as architecture, security, software engineering best practices, etc. And a lot of the influencers out there pushing AI openly admit to "not knowing how to code" let alone knowing the right way to build a technology product so that it scales and is safe.
Is that why we often get so many posts about e.g. getting a huge bill on AWS or GCP? Or that so and so company shut them down or whatever else?
I've seen far too many "temporary" solutions and "quick fixes" that always go beyond the scope and lifetime. Never have such a mindset.
I used a whole lot of "ChatGPT just wrote it all for me" for a rust program that watches for and renames video game clips for me. Maybe it's insecure or has subtle bugs, I don't really care all that much because it does the job for me.
You pretend to not care until you do. When it accidentally deletes your files or even your whole hard drive you'll suddenly find someone / something to blame.
As I tried to allude too, AI written APIs often have security, performance, maintainability and a whole slew of other issues.
But at the same time, I think "blank video on your phone for 20 minutes" is a bit of a stretch. These AI generated APIs have problems for certain but they are working software and in many cases better working software than a non-coder or junior engineer could have written in a much longer time.
And while I don't like the idea of tons of insecure poorly architected APIs being out there, the realty is, people are using AI generated APIs in the real-world right now, it's not hypothetical.
What is "working" software?
Have we lost the meaning of that now too? Samsung Galaxy Note 7 is a "working phone" too - it just might explode.
> but they are working software and in many cases better working software than a non-coder or junior engineer could have written in a much longer time.
Imagine the nurse telling you that you've got an AI doctor operating on you that's better than the junior surgeon. I'm sure you'd be happy. We've been cheapening the industry for a long time. Not everyone needs to produce code.
> the realty is, people are using AI generated APIs in the real-world right now, it's not hypothetical.
The reality is there is contaminated cooking oil [1], noodles with opium [2] and a infinite amount of issues. Let's not make the world worse?
[1]: https://www.abc.net.au/news/2024-07-13/cooking-oil-contamina...
[2]: https://www.washingtonpost.com/news/morning-mix/wp/2014/09/2...
Let's keep your analogy: AI isn't producing software that is the equivalent of a AAA movie title by any stretch but it is producing far better than a bunch of kids in a garage with their cell phones can make. Which is orders of magnitude better than 20 minutes of blank video. Which means that people will use it whether you like it or not.
Reality doesn't care if you think it is a bad idea... in fact I think you and I are on the same page, I do think it is a bad idea... but reality will continue to exist whether you and I like it or not.
You're not helping anyone by arguing how crappy and harmful it is to someone who already knows how crappy and harmful it is.
In rust Oxide had to write their own [1] which is actually decent, but you really need to know it exists.
Barebones? Sure. But far from "a mess".
I've been advocating for finding a better data definition system for Moonwalk (and yes, that's my name on the post-2016 JSON Schema drafts- it's a great runtime constraint system, and it could still be useful for that purpose alongside a system more tailored to data definition).
[1] https://modern-json-schema.com/json-schema-is-a-constraint-s...
I genuinely think that the quality is beyond what exists in the GraphQl ecosystem.
I still think OpenAPI usage is a bit confusing in general. For example, I am still waiting for a better explanation of this diagram with relation to a choice of backend (Python WSGI) + frontend (JS) combinations. Perhaps someone here has a pointer for me to read?
But man, my tokenizer is in trouble with OpenAPI and OpenAI.
Realised that writing a consistent API was more effort than it was worth compared to the one-shot setup cost of creating a set of basic components and re-using them to generate interfaces. Most of the API layer is just boilerplate and we can focus more on biz logic instead.
We knew that OpenAPI is already great at describing the interaction points between a client and server, and this ended up being a perfect fit for the plugin definition too.
Since there is already so much OpenAPI spec out there, I think more people should build tooling based on it. Being able to take types that a server application already knows well, and reuse them to just interact with the client code locally in-process vs. interact with a client over HTTP is pretty remarkable!
It may have more use to you if your API is quite large or re-uses a lot of components (e.g if you follow something like the JSON:API spec), because you can generate boilerplate from it then.
Can also be useful if there’s another team consuming the API, so you can design new endpoints and figure out the requirements before getting to work. That spec can then be used to generate mock servers or used for e2e testing.
One of the "open secrets" about OpenAPI's history was how Smartbear spun out the OpenAPI spec to be a community-managed spec, but with the requirement that there wouldn't be official tooling offered with it --- arguably to protect Smartbear's investment in Swagger. (it's been a minute so specifics are hazy but IIRC it was something like this). The tooling ecosystem feels pretty disjointed as a result.
Compare to gRPC/protobuf, where the specification and tooling have been developed together. Parsers, static analyzers, code generators, documentation tooling all happen in lockstep with spec development, and the ecosystem feels much more cohesive.
That kind of seems backwards. If there was a official tooling, it would be Smartbear's (who else would provide it?) This clause actually seems to be designed to limit Smartbear's ability to use OpenAPI to push their products (and at the same time push OpenAPI as a credibly vendor-independent spec).
> Compare to gRPC/protobuf, where the specification and tooling have been developed together.
Yes, because it's a protocol pushed by one company, not pretending to be independent.
OpenAPI also has the problem of not providing any guidance on what the tooling ecosystem ought to look like, regardless of who implements the tools. You want enough leeway to encourage innovation, but if you don't put out _anything_, you get... well... this. Lots of tools that don't all fully implement things, and not much in the way of interoperable points of hand-off between tools beyond the format. And when many tools leave off some feature or another (most egregiously, external referencing - down the line in this blog post I'll actually show a concrete solution for that), just sharing the format isn't enough.
I'm hoping that this approach I'm sharing through these blog posts will help us start to shape the ecosystem more. For Moonwalk if nothing else (although I'd love to get 3.x into more of an interoperable state- let's make life better for people working with things now, not just years down the line).
Another advantage of OpenAPI is that you can write your specifications using Rust types (as we do at Oxide with Dropshot: https://docs.rs/dropshot)
edit: Apparently protobuf 3 does have oneof: https://protobuf.dev/programming-guides/proto3/#oneof. They look like they solve the problem but I can't vouch for it, and they appear to have some edge cases ("only the last member seen is used in the parsed message"). Thrift doesn't appear to, still.
And I do think being able to write the spec using Rust types is really nice -- you still get an OpenAPI document as an artifact, and (for external users) you get wide client compatibility.
We actually have a plan for supporting multiple versions, and conversions between the corresponding types, using Dropshot as the place where that's coordinated.
There's a required top-level parameter called version. As you are writing the document, it's in your face.
gRPC requires brittle compilation of the protobuf definitions that has impacted every marshalling/serialization protocol for remote procedure calls since XDR.
Whether you like it or not, HTTP/JSON are the lingua franca of the internet (at least the API side of things). Protobuf is good if you are in control of both sides of the API, less so if you are just the server. It also is much less self-documenting than JSON Schema/OpenAPI.
Interacting with the API is very simple, for example:
const resp = await gameEventClient.getRecentAnnotatedGames({
limit: annotatedPageSize,
offset: recentAnnotatedGamesOffset,
});
setRecentAnnotatedGames(resp.games);
These function calls are typed and a lot of the code is auto-generated from the .proto spec (i.e. above the gameEventClient and getRecentAnnotatedGames are auto-generated code). On the server side the code is also obviously auto-generated. It all works seamlessly. Even the documentation for the API can be auto-generated. See for example:https://buf.build/domino14/liwords
The above documentation was auto-generated from my protobuf files. This project uses ConnectRPC on the backend and on the front-end SPA. To me it seems so much simpler and better than the way I've seen people use OpenAPI - where many people seem to create the code _before_ creating the spec. I actually haven't found a good Go generator of stub code from an OpenAPI spec. With ConnectRPC it just works, it's simple, easy, fast, etc. It's easy to add interceptors to do things like parse the http request for an Auth or Cookie header and then insert the user ID etc back into the context for the different service functions to handle whatever needs to be done with the authenticated user.
I could ask the same question - what am I missing?
> "It's much easier to use the API with JSON + a web browser, but the protobuf option is still available..."
... which sort of underscores my perspective (which is admittedly strongly biased towards / empathetic with the API consumer side).
[meta: IMHO this is an exemplary HN interaction; instead of shouting past each other, we shared very different points of view, and one of us learned something potentially useful.]
Any idea how monstrous migrating from gRPC to ConnectRPC might be, on the backend?
https://connectrpc.com/docs/go/grpc-compatibility/
It might not be super simple. Good interaction, I agree :)
TLDR: there should be no migration cost.