5 Lessons Learned About swagger-typescript-api

Christopher Jeffery
5 min readSep 9, 2022

What they don’t tell you in their documentation.

Photo by Newpowa on Unsplash

There’s no sense in writing code that can be generated. The issue I’ve encountered is that code generation is rarely a one-size-fits-all.

I used swagger-typescript-api and learned several lessons while creating customized templates, making the process much easier.

Here are the five lessons.

1. They use Eta syntax.

Eta is a JavaScript/TypeScript template engine that allows us to create templates for code generation.

So, look no further. Learn the syntax from Eta’s site.

2. Unused imports get removed from the generated code.

I take small steps when writing code. I want to get each step right before moving on to the next step so that it’s easier to debug issues as they come up.

I started my custom template by writing an import statement and checking the output. However, the import statement never showed up. I would write gibberish, and the gibberish would show up, but the import statement was always missing. I spent too much time wondering why I could not import my code, but other import statements were showing up.

--

--

No responses yet