swagger-api / swagger-api/swagger-parser

OpenAPIV3Parser.resolve() should handle all errors in the entire spec

Open
#2,149 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Hi, currently we've faced the issue on our project:
OpenAPIV3Parser.resolve() is wrapped with the try-catch and when any error occurs within it, e.g. path is incorrect or a component is wrongly defined, the exception is thrown and caught by that try-catch (typical try-catch behaviour). In this way the spec validation stops and not proceeded to further paths and components:

private SwaggerParseResult resolve(SwaggerParseResult result, List<AuthorizationValue> auth, ParseOptions options,
        String location) {
    try {
    	// any exception here stops the spec parsing

    } catch (Exception e) {
        LOGGER.warn("Exception while resolving:", e);
        result.getMessages().add(e.getMessage());
    }
    return result;
}

It would be perfect to collect all such errors and not to get limited to a single one.
Please tell if it's possible,
Many thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at OpenAPIV3Parser.resolve(), especially its try-catch around spec resolution. Review how exceptions are added to SwaggerParseResult messages and determine how resolution can continue across paths and components; done means the result contains errors from the entire spec rather than stopping after the first exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.