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

[REQ] [maven] improve error message when <inputSpec> cannot be loaded/found

Open tomsit-ionos opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

Disclaimer: it's not a feature nor a bug, but an improvement but i didnt see that option.

When the <inputSpec> cannot be loaded from an URL (in my case when access permission is missing) there's a huge stacktrace, like so:

java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml
    at ... lots of stack frames ...
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml
[WARNING] Exception while reading:
io.swagger.v3.parser.exception.ReadContentException: Unable to read location `https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml`
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml at ... lots of stack frames ...
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml
    at ... lots of stack frames ...
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml
    at ... lots of stack frames ...
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml
    at ... lots of stack frames ...
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml
    at ... lots of stack frames ...
Caused by: java.io.FileNotFoundException: https://raw.githubusercontent.com/my-repo/foo/bar/v0.ea.yml java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.OpenAPI.getExtensions()" because "openAPI" is null
    at ... lots of stack frames ...
java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.OpenAPI.getExtensions()" because "openAPI" is null
    at ... lots of stack frames ...

Reading this usually from the bottom up, it hard to graps what the problem is w/o going all the way up and not overlooking the relevant: java.io.FileNotFoundException: Especially when the URL is correct but one lacks the proper token -- or in my case used a tag or branch that disappeared.

Describe the solution you'd like

In the meanwhile I have learned this, but for the new comers it would be helpful to have a more telling/verbose error message it at the bottom/last Exception

Smth. along these lines:

Error: <inputSpec> @ ${path/url} cannot be loaded (URL returned 404).

If there is an <auth> config'ed, then also add a hint like so:

You have provided an `<auth>` config. In some cases insufficient authorizations are reported as 404s.

Describe alternatives you've considered

n/a

Additional context

n/a

tomsit-ionos avatar Jun 17 '24 16:06 tomsit-ionos