Open JoseHdez2 opened 7 years ago
Are you using jackson ? Can you show me your command line ?
Try adding -g jackson.
Hello @jpbelang, thank you and sorry for the late follow-up; I was working with a temporary solution (deleting the interfaces and working with just the entities) and forgot to check for replies.
I've been using the latest raml-to-jaxrs-cli
, version 2.1.0. I run the JAR executable in the CLI and give the parameters.
Using npm install -g jackson
shows me I have jackson@0.1.4
installed.
can you share the full command used to run the CLI?
@jstoiko I am using a bash script I made, which really just runs the JAR:
#!/bin/sh
jar_path="/home/user/Documents/raml-for-jax-rs/raml-to-jaxrs/raml-to-jaxrs-cli/target/raml-to-jaxrs-cli-2.1.0-jar-with-dependencies.jar"
api_dir="/home/user/Documents/project/submodule/src/main/java/"
raml_path="/home/user/Documents/project/submodule/src/main/resources/my_raml.raml"
model_pkg="com.project.model"
resource_pkg="com.project.resource"
support_pkg="com.project.support"
cmd="java -jar $jar_path -d $api_dir -m $model_pkg -r $resource_pkg -s $support_pkg $raml_path"
echo $cmd
eval $cmd
The files are generated just fine; my initial problem is when using the generated code for PUTting or POSTing an entity. I hope this helps.
Your script is short the -g jackson option. You are only generating the classes and not the jackson annotations.
I swear I'll make that annotation mandatory. :-) (I think you are the third person in the last two weeks that has had that problem.
Thank you very much @jpbelang! Haven't been able to un-scramble the implementation code I had written, but I follow up on Monday to hopefully inform you that it works :+1:
Hello, I haven't closed this issue because I still have a problem with the generated classes and the model interfaces (ex. Product) not being mapped to their corresponding implementation class (ex. ProductImpl) in the resources.
I set the -g jackson
flag, and now see the @JsonDeserialize
Java annotation (and others) is being generated in the model interfaces. My problem now is that some of the model interfaces don't have this annotation.
I thought that it might be faulty difference checking in the generator, but I deleted all the generated model classes and regenerated, and again some were missing the annotation.
I don't know what might be the cause of this, but if I find a common characteristic of the faulty interfaces I'll let you know.
Maybe this is unrelated, but the ResponseDelegate.java
has changes even though I haven't made more changes in the resource types or traits, just the resources and types.
Hi, I have the same problem generating the model interfaces. All endpoints which use entities without @JsonDeserialize
Java annotation are inaccessible.
Any idea?
Thx. Regards.
@JoseHdez2 If you could send me and Example, that would be helpful.
@jairamrb inaccessible ? I don't understand.
@jpbelang
For example, I have in my RAML the types Model1, Model2, Model3, etc.
When I generate them (into the model
package), they are generated as Java interface
s with corresponding implementation classes (Model1Impl, Model2Impl, Model3Impl, ...).
Most of these interfaces
do have the @JsonDeserialize
annotation, pointing to their corresponding implementation:
@JsonDeserialize(
as = com.example.ModelXImpl.class
)
public interface ModelX {
// ...
}
while some are generated (repeatedly) with nothing:
// There should be an annotation here, but nothing is generated.
public interface ModelY {
// ...
}
Right now I don't know why this happens, but it is probably why my problem still exists after applying the -g jackson
flag to the generator.
Also, all of the implementation classes have @JsonInclude(JsonInclude.Include.NON_NULL)
and @JsonPropertyOrder({/* ... */})
annotations, there is nothing wrong with them.
Excuse me @jpbelang, I did not express myself well. When I try to call a POST method, a 500 error is generated. However, if I change the arguments of the methods from interface to implementation, it works correctly.
Ah. Ok @JoseHdez2 . Can you give me a class diagram ? I'll build an example with that.
@jairamrb this might relate to your problem. If the @JsonDeserialize is not on an interface, jackson can't figure out what the class to actually implement is.
Hello @jpbelang, I'm a colleague of @JoseHdez2, we still have the same problem, working for fixing it but not lucky. I'll give u a specific example, hope u can help:
If u need some more information just tell us, we will be checking the post. Thank you so much.
Using npm install -g jackson shows me I have jackson@0.1.4 installed.
That doesn't sound right. This is a nodeJS package... I believe @jpbelang was referring to Java's Jackson Project.
@igc23: do you have a RAML file to share?
Hello @jstoiko, it's attached to my previous comment. I can't share the full and real file because it's business logic of the company, but the important thing is what is already attached. Anything else u need, just tell us. Thank you!
Hello @jstoiko and @jpbelang,
Is there any way to generate the architecture based on the raml file (version 1.0) without including the interfaces? I am referring to the interfaces of the data model, as it happened in version 0.8.
We currently use the following Jackson version:
Hi @jpbelang, Do you know, more or less, when 3.0.5 is planned to be released? Or at least when the code is available in the branch? It would be very nice to have this no-interface generation. thanks!
3.0.5 should be released this week, but I haven't had time to get to no interfaces (the problem is with plugins). It's the next one....
Problem
I'm generating a model and its API methods using raml-to-jaxrs, more specifically raml-for-jaxrs-cli 2.1.0.
My model has two generated classes,
Product
being aninterface
andProductImpl
its implementing class.An example, with one of the API endpoint methods:
PUT
aProductImpl
entity. It fails with a500
response. This is unexpected behavior.If I change it to:
I've Tried
GET
method (which does not capture any parameters aside from thesessionToken
). It works.Product
interface for itsProductImpl
implementing class (as shown in the example). It works.In-depth
I'm using jersey 2.11 and tyrus-container-grizzly-server 1.13 as Maven dependencies.
The error that is returned from the request is:
(StackOverflow question)