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

Configuration propertyWordDelimiters are used for properties but ignored when naming new Java types #73

Closed
joelittlejohn opened this issue Jun 23, 2013 · 4 comments
Milestone

Comments

@joelittlejohn
Copy link
Owner

Original author: [email protected] (August 27, 2012 20:40:54)

What steps will reproduce the problem?

  1. With the maven configuration option propertyWordDelimiters set to: _-
  2. And then using a schema such as the following:
    {
    "description":"New user information",
    "type":"object",
    "properties":{
    "first_name":{"type":"string"},
    "last_name":{"type":"string"},
    "email":{"type":"string"},
    "service_credentials":{
    "type":"array",
    "items":{
    "type":"object",
    "properties":{
    "service":{"type":"string"}
    }
    }
    },
    "additional_info":{"type":"string"}
    }
    }

What is the expected output?
-A ServiceCredential object should be created to represent the array of objects that is attached to the main CreateUser object.

What do you see instead?
-An object named Service_credential is created instead of ServiceCredential. To me it seems like the propertyWordDelimiters flag is being ignored for inner objects/arrays.

What version of the product are you using? On what Java version? (On what
version of Maven/Ant if applicable?) v0.3.2 on Java 1.6

Original issue: http://code.google.com/p/jsonschema2pojo/issues/detail?id=73

@joelittlejohn
Copy link
Owner Author

From [email protected] on August 27, 2012 20:47:20
Thanks for the detailed report Josh.

The problem is even simpler than you think. propertyWordDelimiters are not used when naming Java types, only when naming Java properties. This is a definite oversight and I'll look to get this fixed in 0.3.3.

@joelittlejohn
Copy link
Owner Author

From [email protected] on August 27, 2012 21:49:01
Thanks Joe. If I get a minute later today I'll checkout the code and see if I can fix it and send you a patch.

@joelittlejohn
Copy link
Owner Author

From [email protected] on August 27, 2012 21:52:44
That would be great. I think PropertyRule#capitalizeTrailingWords(String, char[]) needs to be pulled out into some kind of helper so that it can be used from ObjectRule too.

@joelittlejohn
Copy link
Owner Author

From [email protected] on August 29, 2012 21:26:15
I've merged your patches Josh, they both look great. I think you're code fits perfectly (style-wise) with the rest of the project. I've done some further (minor) refactoring to move the illegal char escaping into the name helper and fix some tiny formatter problems (e.g. tabs -> spaces).

I've expanded the Enum integration test to make sure that the new naming strategy is working as expected. Feel free to build the current master and see if everything is working well for you.

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

1 participant