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

Support conversion for value types in models #110

Open
bedag-moo opened this issue Sep 17, 2015 · 1 comment
Open

Support conversion for value types in models #110

bedag-moo opened this issue Sep 17, 2015 · 1 comment

Comments

@bedag-moo
Copy link

We sometimes use custom value types to enforce type safety in our model, and register converters to unwrap these values into strings. Is there any way we can have the doclet recognize these type replacements when generating the swagger documentation?

Specifically, I have something like:

public class Model {
    public TechId id;
}

@XmlJavaTypeAdapter(TechId.XmlConverter.class)
public class TechId {
    private final UUID uuid;

    public TechId(String s) {
        uuid = UUID.fromString(s);
    }

    @Override
    public String toString() {
        uuid.toString();
    }

    public static class XmlConverter extends XmlAdapter<String, TechId> {
        @Override
        public TechId unmarshal(String v) throws Exception {
            return new TechId(v);
        }

        @Override
        public String marshal(TechId v) throws Exception {
            return v.toString();
        }
    }
}

and was hoping for the doclet to recognize the type replacement, but it didn't, i.e. the type of Model.id is not string, but TechId with a property uuid.

@bedag-moo
Copy link
Author

Meanwhile, I found the -stringTypePrefixes option, which can act as a work around. I must have missed it in the wall of options.

Still, if it isn't too much trouble, it would be nice for the doclet to detect the type mapping automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant