Skip to content

Conversation

Deuchnord
Copy link

@Deuchnord Deuchnord commented Jan 8, 2020

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tickets fixes #162
License MIT
Doc PR

Fixing an issue that makes some words in property names being singularized/pluralized, when they actually are not nouns (e.g., same as in the Thing schema should not be singularized in same a).
To fix this, we separate the words in the property name and check that the last word is more than 2 letter long [1]. If it is, then it is singularized/pluralized, otherwise it remains as is. The rest is left unchanged.


[1]: in English, two-letter long words are in majority acronyms, and the rest are not nouns. See https://en.wikibooks.org/wiki/Scrabble/Two_Letter_Words

@Deuchnord Deuchnord force-pushed the do-not-singularize-two-letter-words branch from cf9de06 to 978f9a7 Compare January 8, 2020 16:16
@dunglas
Copy link
Member

dunglas commented Jan 8, 2020

Shouldn't this be fixed in the Inflector library directly?

@Deuchnord
Copy link
Author

I actually wondered the same question, but the Inflector library singularizes/pluralizes single nouns only. Here, we use it to do the same on properties eventually named with several words, so it seemed to me the change was to be done here.

@Deuchnord Deuchnord force-pushed the do-not-singularize-two-letter-words branch from 978f9a7 to 269cce0 Compare January 9, 2020 10:00
@soyuka
Copy link
Member

soyuka commented Jan 10, 2020

linting

@Deuchnord
Copy link
Author

Deuchnord commented Jan 10, 2020

linting

already fixed by #189, rebasing and making perf fixes after discussion IRL with @dunglas ;)

@Deuchnord Deuchnord force-pushed the do-not-singularize-two-letter-words branch from 269cce0 to 1a2db3c Compare January 10, 2020 09:52
@Deuchnord Deuchnord force-pushed the do-not-singularize-two-letter-words branch from 1a2db3c to 25318e5 Compare January 10, 2020 10:09
@dunglas dunglas merged commit 31f0f9a into api-platform:master Jan 10, 2020
@dunglas
Copy link
Member

dunglas commented Jan 10, 2020

Thanks @Deuchnord

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.

SameAs property in Thing class becomes 'SameA' due to Inflector::singularize used on properties
3 participants