Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating documentation causes ClassNotFound from @ApiImplicitParam #2556

Closed
langecode opened this issue Nov 28, 2017 · 3 comments · Fixed by #2571
Closed

Generating documentation causes ClassNotFound from @ApiImplicitParam #2556

langecode opened this issue Nov 28, 2017 · 3 comments · Fixed by #2571
Assignees

Comments

@langecode
Copy link

Generating documentation from classes containing the @ApiImplicitParam annotation generates huge stack traces if the annotation does not contain either dataTypeClass or dataType parameter.

Q A
Bug or feature request? feature request
Which Swagger-Core version? 1.5.15
Which Java version? 9 build 181

When neither the dataTypeClass nor the dataType property of the the annotation is set an large exception stack trace is printed because the code tries to do classloading of the empty string (the default value for dataType). The type is defaulted to string anyway so maybe the default value in for dataType in the annotation might be set to string to avoid the large stack trace.

This can easily be reproduced generating documentation from a class that contains an @ApiImplicitParam annotation with no value set for either dataTypeClass nor dataType.

Failed to resolve '' into class
java.lang.ClassNotFoundException:
        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 io.swagger.util.ReflectionUtils.loadClassByName(ReflectionUtils.java:49)
        at io.swagger.util.ReflectionUtils.typeFromString(ReflectionUtils.java:31)
        at io.swagger.jaxrs.Reader.readImplicitParam(Reader.java:475)
        at io.swagger.jaxrs.Reader.processImplicitParams(Reader.java:444)
        at io.swagger.jaxrs.Reader.readImplicitParameters(Reader.java:437)
        at io.swagger.jaxrs.Reader.read(Reader.java:425)
        at io.swagger.jaxrs.Reader.read(Reader.java:172)
        at io.swagger.jaxrs.Reader$read.call(Unknown Source)
@webron
Copy link
Contributor

webron commented Nov 28, 2017

It sounds to me like the bug is that string is assumed. It should actually fail if no type is mentioned. The goal of the annotation is to let you describe parameters on top of the types defined in the method, which means that you are required to provide all details.

@langecode
Copy link
Author

Yeah, that could also be the case. Its just that the current stack trace is rather confusing - took a little debugging to figure out what was happening :-)

@webron
Copy link
Contributor

webron commented Nov 28, 2017

Yeah, that's understandable. Can definitely be improved.

frantuma added a commit that referenced this issue Dec 7, 2017
fix #2556 - updated logging for ApiImplicitParam with no datatype defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants