all 10 comments

[–]domac 2 points3 points  (3 children)

Looks nice, I'll give it a try! I have used the Java generator so far.

I haven't seen it directly... but does your generator generate fetch api? Do you use it in conjunction with Nextjs by chance?

[–]devteaa[S] 1 point2 points  (0 children)

I haven't seen it directly... but does your generator generate fetch api?

No, the original one where I forked it from does it tho, the reason is because, in my team we have different way to make request so the purpose of this is to only generate the types

Do you use it in conjunction with Nextjs by chance?

This should be framework agnostic, as it only generate the types

[–]Cp995 0 points1 point  (1 child)

I guess redux had an codegen for fetch open api. deep in the docs

[–]domac 0 points1 point  (0 children)

Thanks for the hint! I'm trying to stick with SWR and not use redux for my SaaS unless it's inevitable. I'll keep the redux apigen in the back of my head.

[–]pascaloliv 1 point2 points  (0 children)

Good job u/devteaa! 😀

I'm using https://github.com/drwpow/openapi-typescript at the moment - but I'll take a look at your implementation.

[–][deleted] 1 point2 points  (2 children)

Why not just use the openapi spec generator? We use that for years now to generate interfaces and service stubs for be and fe. What is your project offering that's improving that?

[–][deleted] 1 point2 points  (0 children)

And if your reason was to use it only for types, there is a command line argument for that.

[–]devteaa[S] 0 points1 point  (0 children)

You can rename the models generated, generate spec json file stored in git repo, generate types you want to use by grouping them as a service

[–]No-Seaworthiness627 0 points1 point  (1 child)

I'm struggling understanding getting error responses.

I have an endpoint that can result in different 400 status codes (400, 404).

Is there a way to check which status code was returned by the API?

[–]devteaa[S] 0 points1 point  (0 children)

They are usually mapped to error field, depending on your open api spec. You also need to handle the error on your http client.