javaexceptionswagger

Swagger how to properly generate custom exception classes?


I need to generate exception classes using swagger and Im not able to generate themm properly because my custom exception classes extends Exception, and Exception extends Throwable.

So when I say for exemple that the response is oneOf = {Ex1Error.class, Ex2Error.class} those classes extends Exception so the classes will generate missing somethings... is there a way to do this? thanks


Solution

  • Well, for those with the same "problem", there is no way to do that yet.

    As you can see here: https://github.com/swagger-api/swagger-core/issues/730

    The comment from "wenyi189" describes exactly the same issue as me. "It is 2019 now. And this is still not supported. I'm running into the exact problem where I have multiple sub types of APIException. And this APIException extends from RuntimeException from java. For example, if I have a subtype called UnexpectedException and it extends APIException, everything from parent class got picked up including the fields in Throwable.class. Very annoying and still couldn't find a way to get it working."

    So yeah. No way to do that for now!