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

JAXBElement<T> should be converted in type T #175

Closed
sanja224 opened this issue Sep 18, 2017 · 4 comments
Closed

JAXBElement<T> should be converted in type T #175

sanja224 opened this issue Sep 18, 2017 · 4 comments
Labels

Comments

@sanja224
Copy link

Example:
If I have property of type JAXBElement I want that to be converted in 'Context' type instead of 'any' in typescript.
jsonLibrary is already set to jaxb. Maybe I could write something in customTypeMappings but I don't know what.

@vojtechhabarta
Copy link
Owner

@sanja224 customTypeMappings is not solution for this because it doesn't work with generics.

I think it would be good if typescript-generator could handle JAXBElements directly.
Do you have some example (Java class -> TypeScript interface)? Is really just needed to "unwrap" the T type in all cases?

@sanja224
Copy link
Author

sanja224 commented Sep 18, 2017

Yes, I just need the T type unwraped in all cases. I have many examples. Here's one:

These are the properties in the java class

@XmlElement(name = "ExternalReference")
    protected String externalReference;
@XmlElementRef(name = "UserInformation", type = JAXBElement.class, required = false)
    protected JAXBElement<UserType> userInformation;
@XmlElementRef(name = "Source", type = JAXBElement.class, required = false)
    protected JAXBElement<EndPointType> source;
@XmlElementRef(name = "AdditionalContextInfo", type = JAXBElement.class, required = false)
    protected JAXBElement<AdditionalContextType> additionalContextInfo;

This is the output:

 externalReference: String,
 userInformation: any,
 source: any,
 additionalContextInfo: any

This is how the output should look like:

 externalReference: String,
 userInformation: UserType,
 source: EndPointType,
 additionalContextInfo: AdditionalContextType

EDIT: code format

@vojtechhabarta
Copy link
Owner

I committed support for JAXBElement<T>. For your example Java input following TypeScript interface is generated (note also casing):

interface ClassWithJAXBElements {
    ExternalReference: string;
    UserInformation: UserType;
    Source: EndPointType;
    AdditionalContextInfo: AdditionalContextType;
}

Could you please check it if it does what's expected?

@sanja224
Copy link
Author

sanja224 commented Oct 3, 2017

Yes, it works great.
Thanks :))

@sanja224 sanja224 closed this as completed Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants