@ApiImplicitParam weird error when dataType is a generated model
When using @ApiImplicitParam like this:
@ApiImplicitParams({
@ApiImplicitParam(name = "suggestion", value = "New suggestion", required = true, dataType = "NewSuggestion", paramType = "body")
})
When I run my Play Server and open the swagger-ui, I get this error:
[error] application - Failed to resolve 'NewSuggestion' into class
java.lang.ClassNotFoundException: NewSuggestion
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at play.modules.swagger.PlayReader.typeFromString(PlayReader.java:411)
at play.modules.swagger.PlayReader.readImplicitParam(PlayReader.java:387)
at play.modules.swagger.PlayReader.readImplicitParameters(PlayReader.java:360)
at play.modules.swagger.PlayReader.read(PlayReader.java:198)
at play.modules.swagger.PlayReader.read(PlayReader.java:63)
at play.modules.swagger.PlayReader.read(PlayReader.java:57)
at play.modules.swagger.ApiListingCache$$anonfun$listing$1.apply(ApiListingCache.scala:17)
On my Controller, I have the following import, so the class is known:
import models.NewSuggestion;
To fix it, I need to add the package in front of the dataType, which is not wanted since the import are already there and they are always in the "models" folder. Also, I'm trying to do the play framework codegen and it's very difficult to know if a dataType is a model or a primitive type, so I can't program to add "models." or not before the dataType.
To fix it, here is the notation, it should not be needed:
@ApiImplicitParams({
@ApiImplicitParam(name = "suggestion", value = "New suggestion", required = true, dataType = "models.NewSuggestion", paramType = "body")
})
I don't know how to fix it but I think that the @ApiImplicitParams should use the same import as the page it is on.
Thanks
You can try to use "models.NewSuggestion" instead of "NewSuggestion"