Skip to content

openapi3filter: Remove redundant ExcludeResponseBody check#1056

Merged
fenollp merged 1 commit intogetkin:masterfrom
tatsumack:fix/remove-redundant-exclude-response-body-check
Mar 10, 2025
Merged

openapi3filter: Remove redundant ExcludeResponseBody check#1056
fenollp merged 1 commit intogetkin:masterfrom
tatsumack:fix/remove-redundant-exclude-response-body-check

Conversation

@tatsumack
Copy link
Copy Markdown
Contributor

This PR removes a redundant condition check in the ValidateResponse function.

Currently, there are two checks for options.ExcludeResponseBody:

// First check at line 91
if options.ExcludeResponseBody {
    // A user turned off validation of a response's body.
    return nil
}

// Second check at line 97 (redundant)
if len(content) == 0 || options.ExcludeResponseBody {
    // An operation does not contains a validation schema for responses with this status code.
    return nil
}

The second check is redundant because if options.ExcludeResponseBody is true, the function would have already returned at the first check. This PR removes the redundant condition to improve code clarity.

@fenollp fenollp merged commit e3d68dc into getkin:master Mar 10, 2025
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 this pull request may close these issues.

2 participants