Replies: 5 comments 10 replies
-
This would also be really useful for e.g. re-using the generated Blitz API in a react native app (which I will need to do in the future). Love the idea! |
Beta Was this translation helpful? Give feedback.
-
Love the idea! Publishing an OpenAPI spec would be helpful for a variety of things I think. Maybe it could also be used for Static Application Security testing or similar things? |
Beta Was this translation helpful? Give feedback.
-
Related issue: #745 |
Beta Was this translation helpful? Give feedback.
-
So I found there's a thing called OpenRPC which is better suited for our RPC APIs and also supports codegen. So we should investigate this further too: https://open-rpc.org/beginners |
Beta Was this translation helpful? Give feedback.
-
knowing very little about your history or direction i realize there is a high risk of annoying someone with this post. if i am missing any obvious reasons this is a terrible idea, please forgive me. :) i think the strong typing of GraphQL provides two big benefits directly relevant to the issue:
the fact that Blitz is already built using a strict subset of GraphQL (object types, queries, and mutations) definitely doesn't hurt. and this is not so much relevant to the issue but still remarkable, i think if my intent was to build only a GraphQL API, i could see Blitz outperforming all of the existing GraphQL options (Nexus, TypeGraphQL, etc) in terms of DX, because of how code/dependency injection is core to the Blitz process. to go a little off the deep end here, i could maybe imagine a world where you specify plug and play API generators for Blitz (Swagger, GraphQL) the same way you specify a form provider, or the same way you specify client generators for Prisma. but at the end of the day, the "zero API data layer" is really the crown gem of Blitz so i hope i never have to actually use the thing we're talking about! :) but i understand the necessity of a catch-all. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The original feature request: generating a HTTP client for your blitz app's API
At the last meetup, we briefly discussed the idea of a CLI command to generate an NPM package for an HTTP client from your API 💻. I thought it was a pretty good idea, if you have the kind of web app that other developers might want to get direct access to the API.
Fortunately, there is an easier way to give people the ability to generate HTTP clients, as well as other utilities.
OpenAPI
A more elegant approach would be a Blitz recipe to generate an OpenAPI Specification (formerly known as Swagger docs 🕺) based on your app's API routes. Open API has a lot of tools released already to generate HTTP clients in different programming languages based on a specification.
The recipe would produce an openapi.json file that gets served by the app, basically a JSON version of the API output from
blitz routes
.Users could generate HTTP clients that suit their needs:
Best part is you wouldn't have to lift a finger, this is a command that the developers who are integrating with your API could run.
Beta Was this translation helpful? Give feedback.
All reactions