Support for swift OpenAPI generator #14881
Replies: 1 comment
|
I just spent some time researching this. Wasn't particularly happy with the results I came up with but I'll share here in case anyone else wants to try it out or improve on the methodology. Supabase uses Postgrest and Postgrest supports OpenAPI: https://postgrest.org/en/v12/references/api/openapi.html. However, when I try it locally using supabase-cli v1.178.2 by requesting http://127.0.0.1:54321/rest/v1/ I discovered it was using OpenAPI v2 (i.e. Swagger v2) not the latest OpenAPI v3. So that was a little disappointing. Apparently Postgrest doesn't support v3? See: PostgREST/postgrest#932 Then in the comments of the issue above I found some tools to convert Swagger v2 to OpenAPI v3:
Since I was just looking for a proof-of-concept and wanted to test things out I took the Swagger v2 output from http://127.0.0.1:54321/rest/v1/ and plugged it into https://converter.swagger.io/#/Converter/convertByContent. It successfully generated OpenAPI v3 output. I took that output and followed the step-by-step tutorial I found linked in the Swift OpenAPI generator repository. I was able to successfully generate a client following that tutorial but I wasn't in love with the client API. I decided not to invest more time seeing if I could customize it more to meet my needs. Hopefully this helps someone. On a related note, I like the Supabase swift client we have today but I think it would be so much better if the it had better type support or could do some kind of type inference. Then I might not need an OpenAPI generator type solution. Started a discussion about this here: https://github.com/orgs/supabase/discussions/27544#discussion-6863048 |
Uh oh!
There was an error while loading. Please reload this page.
Is the swift openapi generator supported? If so, is there any documentation on how to use it?
All reactions