Skip to content

How to specify custom formatter when using Flask View integration? #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
asjohnston-asf opened this issue Jul 17, 2023 · 3 comments · Fixed by #623
Closed

How to specify custom formatter when using Flask View integration? #618

asjohnston-asf opened this issue Jul 17, 2023 · 3 comments · Fixed by #623
Labels

Comments

@asjohnston-asf
Copy link

Actual Behavior

Our application is upgrading from openapi-core v0.14.5 to v0.18.0. We previously specified a custom wkt formatter by setting self.request_validator in our class that inherits from FlaskOpenAPIView, see https://github.com/ASFHyP3/hyp3/blob/develop/apps/api/src/hyp3_api/routes.py#L173

It appears that FlaskOpenAPIView no longer uses self.request_validator in it's dispatch_request method: https://github.com/python-openapi/openapi-core/blob/master/openapi_core/contrib/flask/views.py#L21

Is there an alternate way to specify a custom formatter when using this integration pattern?

Expected Behavior

N/A

Steps to Reproduce

N/A

OpenAPI Core Version

0.18.0

OpenAPI Core Integration

flask

Affected Area(s)

No response

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

None

@asjohnston-asf asjohnston-asf added the kind/bug Indicates an issue label Jul 17, 2023
@p1c2u
Copy link
Collaborator

p1c2u commented Jul 18, 2023

Hi @asjohnston-asf

Thanks for the report. Formatters were replaced with Format validators (this one suits your use case) and Format unmarshallers. What I forgot is to give possibility to pass those options to unmarshalling processors (FlaskOpenAPIView in this case).

It's a regression so it needs to be fixed in next release.

@asjohnston-asf
Copy link
Author

Agreed, thank you! We'd gotten as far as trying self.request_validator = V30RequestValidator(spec, extra_format_validators={'wkt': validate_wkt}), but (as you indicated) we hadn't found a way to make FlaskOpenAPIView use that format validator.

Similarly, we've previously disabled schema validation of our API responses for our FlaskOpenAPIView by setting self.response_validator to a custom "do nothing" validator. I expect support for response validators is covered under this same issue? Is there an alternative way to disable response validation?

@p1c2u
Copy link
Collaborator

p1c2u commented Jul 22, 2023

Similarly, we've previously disabled schema validation of our API responses for our FlaskOpenAPIView by setting self.response_validator to a custom "do nothing" validator. I expect support for response validators is covered under this same issue? Is there an alternative way to disable response validation?

I plan to add this option but this will need to wait for other changes that are needed for unmarshalling process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants