Comments (11)
Oh yeah, that's the bug. Null types should be created by the emtpy constructor, otherwise the value construcot is used and thhe wrong enum is set. Therfore we should also add a not null test to value constructors. I can do this tomorrow if you want. I'll send you a new request for this.
from raml-java-tools.
I fixed the date stuff and added some tests. The commit was added to the pull request (Fix/union #43).
The serialization needed to be handled seperately. JacksonScalarTypeSerialization can't be used for this, as unions are not serialized as objects, but only single entries of it. I added a date formatter for writing and reading objects with patterns defined in JacksonScalarTypeSerialization.
Should be fine so far.
Best regards
from raml-java-tools.
I found the place where to fix. I'm on it. I will send you a pull request when i'm finished.
from raml-java-tools.
OK, i'm done. Just need to write some test cases, to show that everyhing is working correctly.
All currently setup tests are running without any problems. My changes are more extensive then i thought in the beginning.
Following things needed to be changed:
- Changed complete behaviour of Jackson-Deserialization
- Don't use deserialize to Map anymore, use JsonNode instead
- Added deserialization strategy for every TypeDeclaration
- Unions, Arrays and Any Types are not supported
- Sorting of types for better deserialization (integer before number)
- All Unions are working fine:
- Objects, nil and primitive types
- Inline declaration and type declaration
- Throwing an Ambiguous Exception if ambiguous types are used
- This needs to be done as two String types cannot be distinguished when in Json Format anymore
- Changed ObjectCreation for Unions to create correct inline types
- Changed structure of Unions:
- Changed union name (string | integer | nil => StringIntegerNilUnion)
- Instead of one "any-field" all types have their own field (anyfield was removed)
- This is needed, as validation cannot be done on a single field (imagine a Email (string with pattern) and nil union)
- Created enum of types in unions to allow Switch statements, not asking every field
- Added field creation to JSR303 to add validation for union fields
- Changed naming of union fields to match the given type (Email (type String)) is now used as Email and not as String anymore (isEmail, getEmail)
- Added simple Jackson2 test
TODO:
- Add these changes to jackson (currently on in jackson2)
- Create more complex test cases for jackson2
I hope this will help you and it will find its way into the next release as soon as possible. There is already one more feature i've seen that needs to be done. It's the validation of url parameters (i will do that in the next week, requiring jsr349 standard).
Best regards
Philipp
from raml-java-tools.
I'm going to be reviewing this Sunday (work has me busy....)
from raml-java-tools.
I've merged and added a couple of tests.
NilUnionTypeImpl nilUnionType = new NilUnionTypeImpl();
ObjectMapper mapper = new ObjectMapper();
StringWriter out = new StringWriter();
mapper.writeValue(out, nilUnionType);
NilUnionType b = mapper.readValue(new StringReader(out.toString()), NilUnionType.class);
assertTrue(b.isNil());
}
This seems to fail. I'm working on something to fix it from .getNullValue(ctxt)
from the Deserializer class. Would you agree ?
from raml-java-tools.
Also, not sure if this generated code is necessary for nil types.
if (node.isNull()) {
return new NilUnionTypeImpl(null);
}
from raml-java-tools.
In #42. (I just don't want to break or go against your very helpful pull request).
from raml-java-tools.
I'll merge the other PR. Give it a look then.
from raml-java-tools.
Damn, that's a big class full of if statements. That parser gets on my nerves :-)
There is one thing I would ask you to do: look at this class org.raml.ramltopojo.extensions.jackson1.JacksonScalarTypeSerialization#fieldBuilt
: dates need to be formatted according to RAML rules. Could you add appropriate logic please and one or two tests ?
If you don't have the time, I'll merge on the weekend and do the work. (Last stretch before christmas at work, I don't have tons of time during the week).
from raml-java-tools.
I'm on it
from raml-java-tools.
Related Issues (20)
- Currently, there is an error in dependency versions that needs to be fixed
- Empty arrays are not supported (they were before)
- Subtypes not deserialized properly
- Dates not deserializing properly
- Subtypes in unions aren't working correctly
- Handle types from different libraries in different directories (packages)
- Make builders better
- Use type discrimination methods in the project, not instanceof....
- Handle inline supertypes.
- Inherited inline type not handled correctly HOT 1
- ids should be used for types, not name parsing.
- Plugin to automatically repackage classes in libraries.
- "Recursive Shapes" need to be addressed.
- Migrate pojo-to-raml to AMF
- Have the builders delegate to AMF
- Figure out facets and annotations with AMF (building)
- Differentiate basic type names from user-defines type names.
- Circular definition of types might have problems.
- Handle examples properly HOT 1
- All type appear inline
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raml-java-tools.