redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Detect unused files

Open kekel87 opened this issue 8 months ago • 4 comments

Hello,

We use the multi-file approach to manage our public and internal Api, which are very large. On the other hand, we're starting to have a lot of files, and when we refactor or clean up, we end up with orphaned files. And it's very difficult to identify them.

It would be really cool to have a command to detect them, or even delete them automatically.

Describe alternatives you've considered

Be careful and look for them by hand :sweat_smile:

Additional context

With an organization like this :

📦 api-spec
 ┣  📄 public.vX.yaml
 ┣  📄 internal.yaml
 ┃
 ┣  📂 paths
 ┣  📂 components
 ┃
 ┣  📂 public-vx
 ┃  ┣  📂 paths
 ┃  ┣  📂 components
 ┃  ┗  📂 webhooks

kekel87 avatar Dec 20 '23 16:12 kekel87

Thank you for sharing the idea! I'm not entirely sure about the strategy though. Do we want to cleanup a certain folder? Or shall we look for yaml/json files only (note that there could be other types of files referenced, like .md files)?

tatomyr avatar Dec 28 '23 10:12 tatomyr

Yes, it's a good idea to be able to target a folder to, but also the entire also. Initially, yes, I'd like it to target yaml and json files (do people really write api spec files in json :upside_down_face: ?).

Ideally, it would also go up via the redocly linter and the VS Code extension. Like: This file is not referenced.

kekel87 avatar Dec 28 '23 10:12 kekel87

What action do you expect to take on unreferenced files?

btw, we write all OAS in JSON! :)

jeremyfiel avatar Dec 28 '23 16:12 jeremyfiel

I'm not sure that Redocly can know what "other" files should or should not be present in a directory structure. I have tackled this in the past by using bundle to make a single API definition, then deleting the original files and re-running split. The diff shows which files weren't needed. I'm not sure if this exactly applies to your situation but I thought I'd mention it in case it helped.

lornajane avatar Dec 29 '23 10:12 lornajane

I'm closing this issue because it doesn't make sense to add features for files that might not be related to this tool. I understand the use case, but I don't think this tool can make assumptions about other files confidently enough that we would add this as a mainstream feature, sorry.

lornajane avatar Mar 25 '24 10:03 lornajane