go-openapi / swag

goodie bag in use in the go-openapi projects
Apache License 2.0
184 stars 46 forks source link

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

Open osery opened 4 years ago

osery commented 4 years ago

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 :pray:.

casualjim commented 4 years ago

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 commented 4 years ago

Thank you for the quick response :pray:.

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 commented 4 years ago

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

osery commented 4 years ago

@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).