@@ -204,28 +204,8 @@ protected abstract void serializeContents(T value, JsonGenerator jgen, Serialize
204
204
public JsonNode getSchema (SerializerProvider provider , Type typeHint )
205
205
throws JsonMappingException
206
206
{
207
- /* 15-Jan-2010, tatu: This should probably be rewritten, given that
208
- * more information about content type is actually being explicitly
209
- * passed. So there should be less need to try to re-process that
210
- * information.
211
- */
212
207
ObjectNode o = createSchemaNode ("array" , true );
213
- JavaType contentType = null ;
214
- if (typeHint != null ) {
215
- JavaType javaType = provider .constructType (typeHint );
216
- contentType = javaType .getContentType ();
217
- if (contentType == null ) { // could still be parametrized (Iterators)
218
- if (typeHint instanceof ParameterizedType ) {
219
- Type [] typeArgs = ((ParameterizedType ) typeHint ).getActualTypeArguments ();
220
- if (typeArgs .length == 1 ) {
221
- contentType = provider .constructType (typeArgs [0 ]);
222
- }
223
- }
224
- }
225
- }
226
- if (contentType == null && _elementType != null ) {
227
- contentType = _elementType ;
228
- }
208
+ JavaType contentType = _elementType ;
229
209
if (contentType != null ) {
230
210
JsonNode schemaNode = null ;
231
211
// 15-Oct-2010, tatu: We can't serialize plain Object.class; but what should it produce here? Untyped?
@@ -249,16 +229,16 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
249
229
{
250
230
JsonArrayFormatVisitor arrayVisitor = (visitor == null ) ? null : visitor .expectArrayFormat (typeHint );
251
231
if (arrayVisitor != null ) {
252
- TypeFactory tf = visitor . getProvider (). getTypeFactory ();
253
- JavaType contentType = tf . moreSpecificType ( _elementType , typeHint . getContentType ());
254
- if ( contentType == null ) {
255
- throw new JsonMappingException ( "Could not resolve type" );
256
- }
232
+ /* 01-Sep-2014, tatu: Earlier was trying to make use of 'typeHint' for some
233
+ * reason, causing NPE (as per https://github.com/FasterXML/jackson-module-jsonSchema/issues/34)
234
+ * if coupled with `@JsonValue`. But I can't see much benefit of trying to rely
235
+ * on TypeHint here so code is simplified like so:
236
+ */
257
237
JsonSerializer <?> valueSer = _elementSerializer ;
258
238
if (valueSer == null ) {
259
- valueSer = visitor .getProvider ().findValueSerializer (contentType , _property );
239
+ valueSer = visitor .getProvider ().findValueSerializer (_elementType , _property );
260
240
}
261
- arrayVisitor .itemsFormat (valueSer , contentType );
241
+ arrayVisitor .itemsFormat (valueSer , _elementType );
262
242
}
263
243
}
264
244
0 commit comments