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

Filename of an initialism in plural form (IDs -> i_ds). #46

Open
osery opened this issue Jun 3, 2020 · 4 comments
Open

Filename of an initialism in plural form (IDs -> i_ds). #46

osery opened this issue Jun 3, 2020 · 4 comments

Comments

@osery
Copy link

osery commented Jun 3, 2020

I have a name that is a plural of an initialism (e.g., IDs) in my swagger file. Filename generated out of this name is i_ds, where I would ideally expect ids.

I understand this is hard to solve perfectly for each use case in general. Any ideas how to at least enforce an override for a specific names? I am happy to contribute a PR if we agree on the best approach.

Many thanks 🙏.

@casualjim
Copy link
Member

The splitting logic that we use is here:

https://github.com/go-openapi/swag/blob/master/name_lexem.go
https://github.com/go-openapi/swag/blob/master/split.go

I think we try to detect that list of blessed acronyms and use that as an input to the word splitter

@osery
Copy link
Author

osery commented Jun 3, 2020

Thank you for the quick response 🙏.

My issue is really just with the initialisms in plural, i.e., with the ending "s", e.g., IDs, IPs, etc. This results in go modules (and files) named i_ds and i_ps which seems wrong. At the same time, trying to solve this in general is likely to produce other issues. So I was thinking that there could be an option to add a list of mapping overrides saying, e.g., map IDs to ids or such.

I am happy to try solving in general (or at least for names that are exactly an initialism + "s", not their further composition). Thoughts?

@fredbi
Copy link
Member

fredbi commented Jun 27, 2020

@osery you may use the AddInitialisms() func for that.

@osery
Copy link
Author

osery commented Jun 29, 2020

@fredbi not really. AddInitialisms() only handles the singular case (e.g., VPC -> vpc) but not the plural (e.g., VPCs -> vpcs and results in v_p_cs instead).

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

No branches or pull requests

3 participants