Open ipekt opened 1 year ago
I am also running in to this issue.
Same here.
There seems to be very few tools available for generating API specs from TS types.
This project looks very promising and I like the idea of the contract declaration to have some degree of control over what is exposed in the spec as well.
I've tried some of the others as well (ones which also integrate with serverless framework) - and they too are also all broken and/or abandoned.
It's a shame, because something like this will save a lot of time and effort in allowing 3rd parties to integrate on our APIs without having to do all the spec and client implementation work manually.
This appears to be mostly due to the really old version of ts-morph
that spot uses; I have a local copy updated to ts-morph@18.0.0
and most of these errors go away. I'm still tracking down some other incompatibilities though.
PR to update dependencies just enough to make it work https://github.com/airtasker/spot/pull/2061
EDIT: I have been going deeper using this tool on my types, and I have to say that the definition of "work" is actually quite limited. I don't think I will be able to continue to use this tool with my project, since the types we have are quite complex and the parsing is failing in unknown ways; there's quite a bit of TS which is simply not supported/supportable here. Given that the tool likes to bail out completely rather than skip over parts it cannot handle, it makes debugging the generator and our project types almost impossible, and certainly more work than writing a spec from scratch.
❯ yarn run spot generate -c src/contracts/test.ts --out dist/spec --language yaml --generator openapi3
Error: unknown type
Describe the bug Spot outputs TS errors when
spot generate
command is run in an monorepo. But the same code works fine when it is outside a monorepo. This may be an issue with TS looking at parent node_modules folderTo Reproduce
Create a package.json with serverless in root folder:
Create another package.json in a nested folder: (root/spot)
spot generate --contract api.ts --language yaml --generator openapi3 --out output/
Expected behavior
spot generate
works in a monorepo setupScreenshots Example command line output:
Desktop (please complete the following information):