spring-openapi icon indicating copy to clipboard operation
spring-openapi copied to clipboard

NPE generating spec from controller method returning parameterized type with unspecified type parameter

Open trurli opened this issue 6 years ago • 0 comments

When trying to generate an OpenAPI spec from a controller method returning a ResponseEntity without a type parameter (returning a raw ResponseEntity instead of ResponseEntity<Something>), generation fails with a NPE (because genericType is null):

java.lang.NullPointerException
	at com.github.jrcodeza.schema.generator.OperationsTransformer.isList(OperationsTransformer.java:586)
	at com.github.jrcodeza.schema.generator.OperationsTransformer.createMediaType(OperationsTransformer.java:557)
	at com.github.jrcodeza.schema.generator.OperationsTransformer.createApiResponses(OperationsTransformer.java:234)
	at com.github.jrcodeza.schema.generator.OperationsTransformer.mapRequestMapping(OperationsTransformer.java:143)
	at com.github.jrcodeza.schema.generator.OperationsTransformer.lambda$createOperation$6(OperationsTransformer.java:128)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at com.github.jrcodeza.schema.generator.OperationsTransformer.createOperation(OperationsTransformer.java:128)
	at com.github.jrcodeza.schema.generator.OperationsTransformer.lambda$transformOperations$0(OperationsTransformer.java:112)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:410)
	at com.github.jrcodeza.schema.generator.OperationsTransformer.transformOperations(OperationsTransformer.java:112)
	at com.github.jrcodeza.schema.generator.OpenAPIGenerator.createPathExtensions(OpenAPIGenerator.java:171)
	at com.github.jrcodeza.schema.generator.OpenAPIGenerator.createPathsWrapper(OpenAPIGenerator.java:154)
	at com.github.jrcodeza.schema.generator.OpenAPIGenerator.generate(OpenAPIGenerator.java:105)
	at com.github.jrcodeza.schema.generator.OpenAPIGenerator.generate(OpenAPIGenerator.java:97)

trurli avatar Feb 06 '20 07:02 trurli