ts-spec / tspec

Type-driven API Documentation library. Auto-generating REST API document based on TypeScript types.
https://ts-spec.github.io/tspec/
MIT License
108 stars 5 forks source link

Pets showing up in on my swagger docs #32

Closed RobKohr closed 10 months ago

RobKohr commented 1 year ago

Despite not having anything about pets in my code, I am seeing a pets api on my docs.

image

It looks like it is loading in the pet info from: node_modules/tspec/dist/tests/pet.js

Is there a way to have it ignore this?

hyeonss0417 commented 1 year ago

Thanks for reporting the issue, we'll get that fixed quickly.

In the meantime, to work around that issue, you can use the specPathGlobs option to set only your source files(e.g. "src/*/.ts") to not include node_modules. You can find more information on how to do this at https://ts-spec.github.io/tspec/guide/generating-document.

I'll let you know if this issue is resolved.

hyeonss0417 commented 12 months ago

I tried configuring the project as written in https://ts-spec.github.io/tspec/guide/getting-started to reproduce the issue you reported, but the issue didn't occur. Can you give me more details about the environment where the issue occurred?

Also, when Tspec load the type files, it ignores **/node_modules/** as you can see in the code attached below, so it's strange that it shouldn't happen 🤔.

https://github.com/ts-spec/tspec/blob/9e4a33a29b5b58100e8ecdc6c9c6ac80e6a857c3/packages/tspec/src/generator/index.ts#L81-L88

RobKohr commented 11 months ago

Oh, I figured it out. I set the "rootDir": "../" in order to import routes that were outside of the server's directory in the tsconfig. I was keeping api route files next to their related front end component files and this created issues. I moved them into the server directory and got rid of the rootDir setting and now it looks only where it is supposed to.