@Override public JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("A class must be provided"); } /* First: we need a separate instance, which will hold a copy of the * non-shared ("local") read-only lookup Map for fast * class-to-serializer lookup */ StdSerializerProvider inst = createInstance(config, jsf); // sanity check to avoid weird errors; to ensure sub-classes do override createInstance if (inst.getClass() != getClass()) { throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type "+inst.getClass()+"; blueprint of type "+getClass()); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ JsonSerializer<Object> ser = inst.findValueSerializer(type, null); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(inst, null) : JsonSchema.getDefaultSchemaNode(); if (!(schemaNode instanceof ObjectNode)) { throw new IllegalArgumentException("Class " + type.getName() + " would not be serialized as a JSON object and therefore has no schema"); } return new JsonSchema((ObjectNode) schemaNode); }
@Override public JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("A class must be provided"); } /* First: we need a separate instance, which will hold a copy of the * non-shared ("local") read-only lookup Map for fast * class-to-serializer lookup */ StdSerializerProvider inst = createInstance(config, jsf); // sanity check to avoid weird errors; to ensure sub-classes do override createInstance if (inst.getClass() != getClass()) { throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type "+inst.getClass()+"; blueprint of type "+getClass()); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ JsonSerializer<Object> ser = inst.findValueSerializer(type, null); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(inst, null) : JsonSchema.getDefaultSchemaNode(); if (!(schemaNode instanceof ObjectNode)) { throw new IllegalArgumentException("Class " + type.getName() + " would not be serialized as a JSON object and therefore has no schema"); } return new JsonSchema((ObjectNode) schemaNode); }
@Override public JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("A class must be provided."); } /* First: we need a separate instance, which will hold a copy of the * non-shared ("local") read-only lookup Map for fast * class-to-serializer lookup */ StdSerializerProvider inst = createInstance(config, jsf); // sanity check to avoid weird errors; to ensure sub-classes do override createInstance if (inst.getClass() != getClass()) { throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type "+inst.getClass()+"; blueprint of type "+getClass()); } JsonSerializer<Object> ser = inst.findValueSerializer(type); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(inst, null) : JsonSchema.getDefaultSchemaNode(); if (!(schemaNode instanceof ObjectNode)) { throw new IllegalArgumentException("Class " + type.getName() + " would not be serialized as a JSON object and therefore has no schema."); } return new JsonSchema((ObjectNode) schemaNode); }
@Override public JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("A class must be provided"); } /* First: we need a separate instance, which will hold a copy of the * non-shared ("local") read-only lookup Map for fast * class-to-serializer lookup */ StdSerializerProvider inst = createInstance(config, jsf); // sanity check to avoid weird errors; to ensure sub-classes do override createInstance if (inst.getClass() != getClass()) { throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type "+inst.getClass()+"; blueprint of type "+getClass()); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ JsonSerializer<Object> ser = inst.findValueSerializer(type, null); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(inst, null) : JsonSchema.getDefaultSchemaNode(); if (!(schemaNode instanceof ObjectNode)) { throw new IllegalArgumentException("Class " + type.getName() + " would not be serialized as a JSON object and therefore has no schema"); } return new JsonSchema((ObjectNode) schemaNode); }
@Override public JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("A class must be provided"); } /* First: we need a separate instance, which will hold a copy of the * non-shared ("local") read-only lookup Map for fast * class-to-serializer lookup */ StdSerializerProvider inst = createInstance(config, jsf); // sanity check to avoid weird errors; to ensure sub-classes do override createInstance if (inst.getClass() != getClass()) { throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type "+inst.getClass()+"; blueprint of type "+getClass()); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ JsonSerializer<Object> ser = inst.findValueSerializer(type, null); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(inst, null) : JsonSchema.getDefaultSchemaNode(); if (!(schemaNode instanceof ObjectNode)) { throw new IllegalArgumentException("Class " + type.getName() + " would not be serialized as a JSON object and therefore has no schema"); } return new JsonSchema((ObjectNode) schemaNode); }
@Override public JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("A class must be provided"); } /* First: we need a separate instance, which will hold a copy of the * non-shared ("local") read-only lookup Map for fast * class-to-serializer lookup */ StdSerializerProvider inst = createInstance(config, jsf); // sanity check to avoid weird errors; to ensure sub-classes do override createInstance if (inst.getClass() != getClass()) { throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type "+inst.getClass()+"; blueprint of type "+getClass()); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ JsonSerializer<Object> ser = inst.findValueSerializer(type, null); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(inst, null) : JsonSchema.getDefaultSchemaNode(); if (!(schemaNode instanceof ObjectNode)) { throw new IllegalArgumentException("Class " + type.getName() + " would not be serialized as a JSON object and therefore has no schema"); } return new JsonSchema((ObjectNode) schemaNode); }