FasterXML / jackson-module-jsonSchema

Module for generating JSON Schema (v3) definitions from POJOs
371 stars 135 forks source link

HyperSchema does not generate links for nested objects #104

Closed alexpeelman closed 8 years ago

alexpeelman commented 8 years ago

Hi, I was expecting that nested objects would be handled as well and that the links property would be added to the schema. I found that somewhere in the recursion path the normal SchemaFactory was used instead of the HyperSchemaFactory.

After digging in the code I pinpointed that HyperSchemaFactoryWrapperFactory only overrides

public SchemaFactoryWrapper getWrapper(SerializerProvider p)  

and should also override

public SchemaFactoryWrapper getWrapper(SerializerProvider  rovider, VisitorContext rvc) 

I guess the following should work

private static class HyperSchemaFactoryWrapperFactory extends WrapperFactory
{
    @Override
    public SchemaFactoryWrapper getWrapper(SerializerProvider p) {
        SchemaFactoryWrapper wrapper = new HyperSchemaFactoryWrapper();
        wrapper.setProvider(p);
        return wrapper;
    };

    @Override
    public SchemaFactoryWrapper getWrapper(SerializerProvider provider, VisitorContext rvc)
    {
        SchemaFactoryWrapper wrapper = new HyperSchemaFactoryWrapper();
        wrapper.setProvider(provider);
        wrapper.setVisitorContext(rvc);
        return wrapper;
    }
};
cowtowncoder commented 8 years ago

@alexpeelman Thanks! I agree, fixed as suggested.

alexpeelman commented 8 years ago

Cool, that was quick ;)