You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Play2/scala: A property named "is_persistent" gets shortened in the json to "_persistent" #415
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/415#issuecomment-32786394
.
We just got bit by this today. Our application didn't know that it needed to convert "is*" parameters in order to be consistent with the generated spec.
Is this documented somewhere? Any other automatic conversions that we should be aware of besides "is_" and "get_"?
is/has (boolean), get/set (other) are typical for POJOs, and are used to determine a property name (getFoo => foo, isFoo => foo, etc.) is_, has_ can have special treatment. To be clear, you're looking to see that is_* is preserved?
Looks like this is an issue with both the internal (1.3.x) introspection and jackson as well (1.5.x). Since the focus is on 1.5.x right now, I'm looking into a solution.
The Jackson BeanDescription method findProperties() is taking public property names like such:
is_persistent gettersAndHaters
and mangling them to _persistent and tersAndHaters
I could use some help from @cowtowncoder on this one:
Right: isXxx methods are auto-detected if enabled by visibility (separately controlled as "is-getters", distinct from "regular" getters) AND return type is boolean or Boolean.
If detected, name mangling is identical to get methods.
If the goal is NOT to detect these methods, it is easy enough to change by changing visibility levels.
One way is with @JsonAutoDetect; another with ObjectMapper.setVisibility(), which can either:
Change level for specific kind of accessor (setter, getter, field, is-getter, constructor), or
Use a fully custom VisibilityChecker
There is no simple overridability wrt name mangling (to perhaps avoid "is_persistent", when naming scheme would expect camel-case), although it might be possible to find overrides that work there.
So the question is just what is the desired behavior.
Hi guys
your decision is not clear correct
there are correct getters and setters with lower case after 'get', for example for property 'aName' getter will be named 'getaName'. intellij idea generates it and considers it is valid
your check !Character.isUpperCase(altName.charAt(offset)
should replace with !Character.isUpperCase(offset) && !Character.isLowerCase(offset)
special simbols ('_' for example) is not upper or lower case
@dmn1899 commenting on an issue that was closed over two years ago is not the way to do it. If you experience an issue with the latest version, consider submitting a new ticket with the details.
Activity
fehguy commentedon Jan 20, 2014
Hi, this is due to this logic:
https://github.com/wordnik/swagger-core/blob/develop/modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala#L73
Looking at alternatives to just detecting "is_"
kieranbenton commentedon Jan 21, 2014
Under what circumstances are you trying to strip the 'is' off? I can't find
any reference to when Scala might automatically add that prefix?
Cheers.
On 20 January 2014 18:52, Tony Tam [email protected] wrote:
mkantor commentedon Mar 20, 2014
We just got bit by this today. Our application didn't know that it needed to convert "is*" parameters in order to be consistent with the generated spec.
Is this documented somewhere? Any other automatic conversions that we should be aware of besides "is_" and "get_"?
fehguy commentedon Apr 8, 2014
is/has (boolean), get/set (other) are typical for POJOs, and are used to determine a property name (getFoo => foo, isFoo => foo, etc.)
is_,has_can have special treatment. To be clear, you're looking to see thatis_*is preserved?mkantor commentedon Aug 9, 2014
The way it's written, even properties with names like "isometric" get mangled. This definitely isn't desirable behavior.
added test output for debugging #415
fehguy commentedon Jan 10, 2015
Looks like this is an issue with both the internal (1.3.x) introspection and jackson as well (1.5.x). Since the focus is on 1.5.x right now, I'm looking into a solution.
The Jackson
BeanDescriptionmethodfindProperties()is taking public property names like such:is_persistentgettersAndHatersand mangling them to
_persistentandtersAndHatersI could use some help from @cowtowncoder on this one:
https://github.com/swagger-api/swagger-core/blob/develop_2.0/modules/swagger-core/src/main/java/com/wordnik/swagger/jackson/ModelResolver.java#L172
Where the properties in this test class:
https://github.com/swagger-api/swagger-core/blob/develop_2.0/modules/swagger-core/src/test/scala/models/ModelPropertyName.java
emerge mangled
cowtowncoder commentedon Jan 10, 2015
Right:
isXxxmethods are auto-detected if enabled by visibility (separately controlled as "is-getters", distinct from "regular" getters) AND return type isbooleanorBoolean.If detected, name mangling is identical to
getmethods.Jackson 2.5 has a new
MapperFeature,USE_STD_BEAN_NAMING: http://fasterxml.github.io/jackson-databind/javadoc/2.5/com/fasterxml/jackson/databind/MapperFeature.html#USE_STD_BEAN_NAMINGwhich can be enabled to change it slightly (earlier
getURLresults inUrl; with STD_BEAN_NAMING_ENABLED, remainsURL), but I don't think it'd have effect here.If the goal is NOT to detect these methods, it is easy enough to change by changing visibility levels.
One way is with
@JsonAutoDetect; another withObjectMapper.setVisibility(), which can either:VisibilityCheckerThere is no simple overridability wrt name mangling (to perhaps avoid "is_persistent", when naming scheme would expect camel-case), although it might be possible to find overrides that work there.
So the question is just what is the desired behavior.
fehguy commentedon Jan 10, 2015
Thanks, any way to detect as "getXxx" as a getter and not treat "getxxx" as a getter? Likewise "isXxx" is a getter but "isxxx" or "is_xxx" is not
2 remaining items
fix for #415, added handling for get/is
fehguy commentedon Jan 10, 2015
It's a hack but it works:
d183d8c
Required
getto be followed by an uppercase or uses original field name. Same behavior foris.webron commentedon Jan 12, 2015
Applies to https://github.com/swagger-api/swagger-core/milestones/v1.5.0-M1 as well.
dmn1899 commentedon Feb 7, 2017
Hi guys
your decision is not clear correct
there are correct getters and setters with lower case after 'get', for example for property 'aName' getter will be named 'getaName'. intellij idea generates it and considers it is valid
your check
!Character.isUpperCase(altName.charAt(offset)should replace with
!Character.isUpperCase(offset) && !Character.isLowerCase(offset)special simbols ('_' for example) is not upper or lower case
best regards, hope you will fix it
webron commentedon Feb 7, 2017
@dmn1899 commenting on an issue that was closed over two years ago is not the way to do it. If you experience an issue with the latest version, consider submitting a new ticket with the details.
EPBDS-14539 Remove usage of @xmlelement in CSR
EPBDS-14539 Remove usage of @xmlelement in CSR
EPBDS-14539 Remove usage of @xmlelement in CSR
Apply PropertyNamingStrategy to get/is-prefixed property names
Honor PropertyNamingStrategy for get/is-prefixed property names (#5192)
Honor PropertyNamingStrategy for get/is-prefixed property names (swag…
Honor PropertyNamingStrategy for get/is-prefixed property names (swag…