Skip to content

Enhance split words #413

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

Merged
merged 2 commits into from
May 24, 2021
Merged

Conversation

ramnes
Copy link
Contributor

@ramnes ramnes commented May 6, 2021

Keep "Response200" as "response_200", but don't make "s3config" become "s_3_config". :)

Related to the comments here: #375 (comment)

@ramnes ramnes force-pushed the enhance-split-words branch 2 times, most recently from ba648d6 to 84192c6 Compare May 6, 2021 10:41
@codecov
Copy link

codecov bot commented May 6, 2021

Codecov Report

Merging #413 (d6cce56) into main (a731477) will not change coverage.
The diff coverage is 100.00%.

❗ Current head d6cce56 differs from pull request most recent head 999a81d. Consider uploading reports for the commit 999a81d to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##              main      #413   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         1549      1550    +1     
=========================================
+ Hits          1549      1550    +1     
Impacted Files Coverage Δ
openapi_python_client/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a731477...999a81d. Read the comment docs.

@ramnes ramnes force-pushed the enhance-split-words branch 2 times, most recently from 321176c to d6cce56 Compare May 6, 2021 10:52
@dbanty
Copy link
Collaborator

dbanty commented May 7, 2021

I'm not totally convinced and I'm worried that this could get bikesheddy and keep becoming more specialized. Like, what if someone wanted HTTP200 to be http_200? Or in the golden records examples, type1 really is type_1 (meaning "the first type").

Happy to get input from others (e.g. @emann, @bowenwr) but I'm tempted to call it good enough and stop making changes to names unless something is really broken. Maybe allowing a manual override of specific values would be good though (e.g. s_3_config -> s3_config), I think we could add that through the normal config process with minor effort.

@ramnes
Copy link
Contributor Author

ramnes commented May 7, 2021

I think we don't want to guess the words if there is no capital letter (i.e. if we're not seeing a PascalCase or camelCase string) because that means we would only split on numbers and will never be able to guess any kind of other word. Plus OpenAPI specifications authors will use some form of delimiters if there really is multiple words that need to be separated for readability anyway.

As to the type_1 being changed to type1 in the golden records, I couldn't find were it came from and assumed it was something internal to openapi-python-client as to how it handles lists, or something in these lines. Am I wrong? If not, we could probably add an underscore or something at the source, before split_words is called.

@dbanty
Copy link
Collaborator

dbanty commented May 7, 2021

Oh I see, I misunderstood the change. For some reason I thought that it was making the snake case version of S3Config "s3_config" instead of "s_3_config" but I see now that it was already "s3_config" and the change here is to make the lowercase variant ("s3config") not be split at all. So my note about HTTP200 is irrelevant, both in main and in this branch it will be http200.

I agree with detecting the use of case and splitting based on that, sounds good. Let's just change build_union_property to put and underscore between type and {i} so the generated code doesn't flip around again 😄.

@ramnes ramnes force-pushed the enhance-split-words branch from d6cce56 to 999a81d Compare May 8, 2021 12:01
@ramnes
Copy link
Contributor Author

ramnes commented May 8, 2021

Ah, done, thanks for the hint!

@dbanty dbanty linked an issue May 21, 2021 that may be closed by this pull request
@dbanty dbanty added this to the 0.10.0 milestone May 24, 2021
@dbanty
Copy link
Collaborator

dbanty commented May 24, 2021

Latest on main breaks e2e 😬. I made a branch enhance-split-words in this repo with the update (or you can just task re).

dbanty
dbanty previously approved these changes May 24, 2021
Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go as soon as the golden record conflict is resolved!

Keep "Response200" as "response_200", but don't make "s3config" become
"s_3_config". :)
@ramnes
Copy link
Contributor Author

ramnes commented May 24, 2021

Rebase went fine on my side, not sure what you meant. :)

@ramnes
Copy link
Contributor Author

ramnes commented May 24, 2021

(and yeah, I did the task re)

@dbanty dbanty merged commit 67db1a1 into openapi-generators:main May 24, 2021
dbanty pushed a commit that referenced this pull request Jun 2, 2021
dbanty pushed a commit that referenced this pull request Jun 14, 2021
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

Successfully merging this pull request may close these issues.

split_words: allow numeric suffix in words
2 participants