python-openapi / openapi-core

Openapi-core is a Python library that adds client-side and server-side support for the OpenAPI v3.0 and OpenAPI v3.1 specification.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: `FlaskOpenAPIView` no longer supports custom response validator

jtherrmann opened this issue · comments

Actual Behavior

Previously, the FlaskOpenAPIView class allowed setting the self.response_validator attribute to a custom validator. This behavior was removed sometime after openapi-core v0.14.5. (This is a follow-up from #618 where this issue was discussed in the context of custom formatters.)

Expected Behavior

With openapi-core==0.14.5 installed, we currently use a custom response validator to effectively disable response validation, like this:

from openapi_core.validation.response.datatypes import ResponseValidationResult

class NonValidator:
    def __init__(self, spec):
        pass

    def validate(self, res):
        return ResponseValidationResult()

Then, in our sub-class of FlaskOpenAPIView, we set self.response_validator = NonValidator.

However, this no longer works with openapi-core==0.18.0. We hope to see this feature restored in a future release.

Alternatively, is there a way to simply disable response validation entirely?

Steps to Reproduce

See the example above.

OpenAPI Core Version

0.18.0

OpenAPI Core Integration

flask

Affected Area(s)

validation

References

#618

Anything else we need to know?

No response

Would you like to implement a fix?

None

Thanks for the fix!

@p1c2u Are there plans to release this fix to production within the near future?

@jtherrmann pre-release version will be available soon, we will need to wait little bit longer with final version.