OpenAPI 3.0.3 Specification Released
github.com
github.com
If you want to take your CI pipeline to the next level you can run it (dockerized, if you want) from a CI step to generate and commit + tag a completely separate repo to have your API SDK generation completely automated. I've written a little about the dumbest possible way you could do it (i.e. manually writing YAML)[1] for when you don't have proper framework support.
openapi-generator also has some really awesome new features and support for different languages, most recent big release was 4.0 (and most recent as of this post is 4.2.3)[2], been meaning to write a bit about that as well since their haskell support gets better and better every time. Super awesome & convenient project, the value being delivered for free is unreal.
[0]: https://github.com/OpenAPITools/openapi-generator
[1]: https://vadosware.io/post/quick-intro-to-manual-openapi-v3/
[2]: https://github.com/OpenAPITools/openapi-generator/releases
I’ve tried pretty much all GUIs that existed a year ago or so, and started with Apicurio which was good, but was missing support for oneOf, allOf and the like.
Switched to Stoplight and it has been great! Love that you can just manage your spec in a repo along with the project.
I've tried both the client and server generators for many languages, and the output was always unusable garbage.
It's bettee to just write your own server and use OAS for validation and type defs.
Are there any issues for these corner cases you've filed that could use more attention? I don't maintain openapi-generator but I can definitely forward them to the maintainers
Which typescript generator are you using? Do you use typescript on the backend too and if so is it easy to keep the generated type definitions in sync? Also for backend what do you use for json schema validation?
Do you literally mean unusable, or it just didn't fit your stylistic preference?
I actually still haven't found a single implementation of a OAS consumer (mock server, type generator, etc.) that implements the whole spec correctly.
The intention is that people use the generators as a base, and if there's something you need that's not implemented, you write the implementation and contribute it back. No single person is going to implement 100% of the spec in their day job, so as an open source project, coverage will be patchy until enough people extend the implementation to cover their own API surface area.
I don't think "it doesn't cover the whole spec" is fair grounds for criticism (though out-of-the-box generator errors are another story).
A spec is useless if it's not fully implemented by any library. Also, I'm fine with imperfect FOSS, but it's frustrating to not know that implementation is incomplete or what exactly is missing. You end up doing trial and error.
All I'm saying is that OAS generators are not net time savers, which you supported yourself by saying that sometimes fixing an implementation is up to the user. That's not a criticism of any person, just a fact.
Ref: https://github.com/OpenAPITools/openapi-generator/pull/5120
I've also written customized templates that removed a lot of the cruft (iirc the JS or TS generator decided to output an API client in three different flavors). Of course the problem there was that the particular generator did not have all code generation in (overridable) templates, but also some hardcoded.
If a viable API documentation tool based on raw unmodified jsonschema with some additions to be able to describe the HTTP actions and parameters, and with the ability to visualize it as documentation, came around then I'd switch in a heartbeat.
[1]: https://datatracker.ietf.org/doc/draft-handrews-json-schema-...
[2]: https://json-schema.org/implementations.html#hyper-schema
Any other projects that are better? Or just projects that can do the "POPO <> JSON" mapping, ideally with type hints so that I can get code completion in my IDE? I'd be fine to manually wire up the HTTP parts for the SDKs that I write if I had a good schema mapper.
There were discussions on type hints but unfortunately no one has found the time to make the contribution yet.
We also have a new `python-experimental` client generator that has better support for new features in OAS v3. Please check it out to see if it works better for you.
IIRC the problems I faced were around things like bearer token auth with JWT being confusing to configure, the general structure of the client being unintuitive for me, and a general lack of examples on how the client was supposed to be used. No problems that I couldn't resolve each in an afternoon, but way harder to work with than a hand-rolled SDK (even considering complex and arguably a bit confusing ones like https://developer.paypal.com/docs/api/quickstart/).
So many things have built-in support that _not using_ it is really costing you. Yeah, sure, the auto-generated clients can suck but mangling that boiler plate into something acceptable probably saved you days of time, if for nothing else but being consistent with its shitty quirks. If it wasn't for OpenAPI I probably would have given up on web-frontends, because it's awful to give a shit about the shape of your data... but you pair it with Ember, which is already aware of it OOB, and kisses the air "it's fucking brilliant."
It works. It's easy enough... and to be honest, absolutely none of us, save for some very real-time, low-latency, applications, have a good reason to not use it... unless you like painting bike sheds ;)
Oh, and since it's REST, you even get nice things like logs that are useful... cough GraphQL cough
components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT
security: - bearerAuth: []
I find GRPC to be much better on server-side and grpc-web + webassembly is starting to be a serious competitor on the frontend as well.
eg https://levelup.gitconnected.com/grpc-basics-part-2-rest-and...
We had the pleasure of working with some legacy SOAP recently - the other end had changed the WSDL such that our client no longer compiled from the WSDL - they couldn't work out what was wrong and where fearful of changing it again so we had to had to hand roll the client. Fun times....
I hope neither get as complex as SOAP - one of potential pitfalls of tooling is it becomes 'free' to add complexity.
Is it perhaps because basic JSON handling and POST/GET processing is still so miserable in most environments?
There are other advantages, like automatic documentation, easier management of versioning, schema/type verification, ...
And of course you don't need a custom library. Its just nicer to have one as it facilitates code completion and leverages the compiler you're using instead of some new validation tool.
I'm bearish on 3rd party SDKs for apis these days as most are fairly thin wrappers around apis that don't add much value but give you little to no control over how the actual http calls are being made.
So you don't need to add "the need" after the word obviate.
You can just say "Wasn't the promise of RESTful APIs to obviate this?"
Otherwise what you are really saying is -> "Wasn't the promise of RESTful APIs to remove the need the need for such?"
Generators are still in need of work for the languages I use, but this is the future.
DRY in action
Please share your feedback by opening an issue via https://github.com/OpenAPITools/openapi-generator/issues/new.... Thanks.
https://www.linkedin.com/learning/building-apis-with-swagger...
You can run Swagger UI and Swagger editor locally via docker like this:
docker pull swaggerapi/swagger-editor && docker run -d -p 80:8080 swaggerapi/swagger-editor
docker pull swaggerapi/swagger-ui && docker run -d -p 81:8080 swaggerapi/swagger-ui
You could also do some really horrific things with XML. YAML isn't amazing but its its a lot more plain. Parsers seems a lot more stable these days because of that.
Listen Notes API is using OpenAPI: https://www.listennotes.com/api/docs/#openapi