Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now that we have "exclude" , maybe we also need "include"? #905

Open
nimohunter opened this issue Mar 25, 2021 · 11 comments
Open

Now that we have "exclude" , maybe we also need "include"? #905

nimohunter opened this issue Mar 25, 2021 · 11 comments

Comments

@nimohunter
Copy link

same to #640 , if the path tree like this:

├── src
│   ├── package_a
│     └── someapi_of_a
│   ├── package_b
│     └── someapi_of_b
│   ├── package_c
│     └── someapi_of_c1
│     └── someapi_of_c2

i just want need generate swagger file in package_c/someapi_of_c2, we have to use

--exclude src/package_a,src/package_b/;src/package_c/ someapi_of_c1

Can it be optimized here?

Describe the solution you'd like
if this is useful and meaning, i'll try to pull request.

@nimohunter nimohunter changed the title Now that we have exclude, maybe we also need to include? Now that we have "exclude" , maybe we also need "include"? Mar 25, 2021
@nimohunter
Copy link
Author

nimohunter commented Mar 25, 2021

i try to use swag init -d ./src/package_c/someapi_of_c2 ,but this "dir value" is not suitable for this situation absolutely.

because if i use "-d " define the root of search path, but some struct out of the root can not be recognized, and return error like cannot find type definition: xxxout_of_root_struct

@nimohunter
Copy link
Author

or maybe we need a new arg like searchroot or something ?

@nimohunter
Copy link
Author

analysis the code, find the reason why return error like "cannot find type definition: xxxxxx" is that search struct define root path is same with Directory you want to parse.

but if your api request or response define struct not located in the the Directory you want to parse. then will return this error.

@nimohunter
Copy link
Author

i find struct type define also be ignore by exclude args, so move the skip excloud path function and add include.
and, if set include, exclude will be invalid

Welcome to discuss this idea :)

@sdghchj
Copy link
Member

sdghchj commented Apr 12, 2021

i find struct type define also be ignore by exclude args, so move the skip excloud path function and add include.
and, if set include, exclude will be invalid

Welcome to discuss this idea :)

So what if one wants to exclude some sub directories in the directory included by --includes.

@nimohunter
Copy link
Author

i find struct type define also be ignore by exclude args, so move the skip excloud path function and add include.
and, if set include, exclude will be invalid
Welcome to discuss this idea :)

So what if one wants to exclude some sub directories in the directory included by --includes.

good question, i'll check whether my pr can support your idea.

this the reason why i want to add this arg:
in some case, i just want to generate a little api interface(for example, src/package_a/), but some struct is define out of src/package_a/, the struct is located in src/struct_define. so i add this arg.

├── src
│ ├── package_a
│ └── someapi_of_a
│ ├── package_b
│ └── someapi_of_b
│ ├── struct_define
│ └── some_struct_define

@nimohunter
Copy link
Author

i find struct type define also be ignore by exclude args, so move the skip excloud path function and add include.
and, if set include, exclude will be invalid
Welcome to discuss this idea :)

So what if one wants to exclude some sub directories in the directory included by --includes.

//checkFileNeedParse Check if this file needs to be parse depend on include and exclude.
// return true is this file need to be parse
func (parser *Parser) checkFileNeedParse(fileName string) bool {
	if len(parser.includes) > 0 {
		if parser.checkFileInIncludes(fileName) {
			return true
		}
		return false
	}
	if parser.checkFileInExcludes(fileName) {
		return false
	}
	return true
}

Do we need to consider the situation where both exist? how to solve it?

@sdghchj
Copy link
Member

sdghchj commented Aug 18, 2021

Now -d support multiple directories seperated by comma, which works the same as --include.
First include, then exclude from the included.
If you still have problems, you had better reorganize your directories, I think.

@ubogdan
Copy link
Contributor

ubogdan commented Sep 24, 2021

@nimohunter any update here?

@iWinston
Copy link

Now -d support multiple directories seperated by comma, which works the same as --include. First include, then exclude from the included. If you still have problems, you had better reorganize your directories, I think.

Any docs for this?

@davidnewhall
Copy link

First include, then exclude from the included.

We aren't given the option to 'include'. We can only provide a search base. I provided a search base, and then excluded my entire project, but it still scans the whole thing and generates docs for it. I'm trying to generate docs for a single file in my entire project. It may share some models, sure, but overall, it's a much smaller interface with a different use case. I can't figure out how to do this. Having include that includes only definitions in a specific folder (or file, in my case) would be extremely handy.

If you still have problems, you had better reorganize your directories, I think.

How? Where do I put this 1 file so I can include only that file in some output? I'd like to keep it where it is, but if there's some way to fix this by moving I can try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants