Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Deserializer not referenced properly on internal class #261

Closed
adjokic opened this issue May 24, 2017 · 5 comments
Closed

Deserializer not referenced properly on internal class #261

adjokic opened this issue May 24, 2017 · 5 comments
Projects

Comments

@adjokic
Copy link

adjokic commented May 24, 2017

Hello,
The generated Java code for RAML types having nested objects does not seem to be done properly.
We can use one of the existing RAML files as an example: /raml-to-jaxrs/jaxrs-code-generator/src/test/resources/org/raml/jaxrs/generator/v10/extendObject.raml

which generates two files:
ObjectOne and ObjectOneImpl. The former looks like the following:

package model;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.lang.Object;
import java.lang.String;
import java.util.Map;

@JsonDeserialize(
    as = model.ObjectOneImpl.class
)
public interface ObjectOne {
  Map<String, Object> getAdditionalProperties();

  void setAdditionalProperties(Map<String, Object> additionalProperties);

  NameType getName();

  void setName(NameType name);

  @JsonDeserialize(
      as = NameTypeImpl.class
  )
  interface NameType {
    Map<String, Object> getAdditionalProperties();

    void setAdditionalProperties(Map<String, Object> additionalProperties);
  }
}

The problem here is that NameTypeImpl.class cannot be resolved.
I have been playing around a bit with the SimpleTypeGenerator and it looks like we'll need to pass in the notion of a surrounding class, perhaps adding it to the TypeContext. Not sure what the best approach is here though.

@jpbelang
Copy link
Contributor

Ah, dude! :-) You always bring up complicated stuff :-)

You are correct. I'll look into doing it. Can't before tomorrow though.

@adjokic
Copy link
Author

adjokic commented May 24, 2017

haha. apologies. please forgive me :)

@jpbelang
Copy link
Contributor

There are, however, limitations to what we can do with unions in java, I think. This isn't one of those cases, I think.

Unions aren't all that natural to static typing languages.

@adjokic
Copy link
Author

adjokic commented May 24, 2017

true. aside from composition, I can't think of any other way to deal with unions.
Once we get this (actually the other ticket #262) to work, I think unions should work nicely.

Not sure if it's worth checking into using generics as a way of composition.

@jpbelang
Copy link
Contributor

Pushed something (not complete) that should fix your issue.

@jpbelang jpbelang added this to Review in 2.1.0 May 28, 2017
@jpbelang jpbelang moved this from Review to Done in 2.1.0 Jun 21, 2017
@jstoiko jstoiko closed this as completed Jul 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
2.1.0
Done
Development

No branches or pull requests

3 participants