r/purescript • u/notnotandre • Mar 23 '23
Generating a purescript client based on Openapi description
Hey there!
I am thinking of creating a small pet project - a UI for some existing REST-api.
And the api I am going to connect to already exposes it's description as an openapi 3.0 json file.
So I am wondering what would be the best way of generating a purescript client.
PS as a plan B I've got servant-purescript (since the api's running on servant)
8
Upvotes
2
u/saylu Mar 26 '23
Unfortunately, I'm not aware of an open source generator for PureScript from OpenAPI. You are probably best off just hand-writing your endpoints.
However, if you'd like an interesting challenge, it is certainly possible to parse an OpenAPI spec and code-generate PureScript types and functions from it. We do this at work!
If you choose to do this then I recommend using the excellent tidy-codegen library for the code generation.
1
u/tbm206 Mar 23 '23
GPT-4?
1
u/wing328 Apr 23 '23
You may consider adding a new generator to the OpenAPI Generator project. Recently, a contributor submitted a PR to add a N4JS client generator: https://github.com/OpenAPITools/openapi-generator/pull/15089, and the PR can serve as a good starting point to add a purescript client generator.
Please open an "issue" (ticket) via https://github.com/openapitools/openapi-generator/issues/new if you need help.