Openapi core httprequest and httpresponse validation

Hello,

Has anyone used openapi-core library to validate http requests and responses before?

What I’m trying to do:
I am using openapi 3.0.3 to describe my api. Since packages does not contain this library I have to import it in my uplink. In order to validate the request I need to pass the request object to the function, however I can not pass the HttpRequest object as a parameter.

#Function call
response = anvil.server.call('validate_request_openapi_schema',response,request)
#Error
anvil.server.SerializationError: Cannot serialize arguments to function. Cannot serialize <class 'anvil._threaded_server.HttpRequest'> object at msg['args'][1]
at /downlink/anvil/_threaded_server.py, line 379
called from /downlink/anvil/_threaded_server.py, line 383
called from /downlink/anvil/server.py, line 47
called from Http_v1, line 118
called from /downlink/anvil/_server.py, line 1340

My only solution is to create a json schema, which validates only the body of the request and I have to validate the other parts of the request on the server module, but I would need to maintain the json schema and openapi file separately.

If someone has some idea of workaround, it would help a lot.

Hi @adorjani.arpad,

Since you’re on a paid plan, would you like us to install openapi-core for you?

Hello @brooke,

That would be amazing. I didn’t know that there is such an option.

If it is possible, then please do so. It would help a lot.

That should now be installed for you! Hopefully, that helps you get around your issue :slight_smile:

Thank you very much. I will test it out in the next couple weeks.