Making plugin respond to custom REST API request

Hello!

I’m experimenting with extending the MM functionality and I need some custom stuff to happen upon a client request. I’d really appreciate a piece of advice to better understand whether I’m heading in the right direction.

I’ve got a plugin running and everything seems to be working just fine: I can respond to HTTP requests, check the URL path, method, parameters, access the API through MattermostPlugin and extend it. Feels very convenient.

However, these are the requests directed to /plugins/mypluginid/some/custom/stuff. Not something the client can use as RPC through the code generated by OpenApi generator from the mattermost-openapi-v4 spec. At least that’s my understanding.

Question is: is it possible to make all of this goodness respond to a REST API request? If so, does it mean I will have to modify both the spec and the core MM server code to support the new requests? (I wanted to avoid that if at all possible.)