Skip to content

Support conversion for value types in models #110

@bedag-moo

Description

@bedag-moo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions