Access oas in proxy from sharedflow

Can I access the open api specification file(json/yml) in my proxy directory(apiproxy/Resources/openapi/my-oas.yml) from a js policy of sharedflow in flowhook???

0 4 284
4 REPLIES 4

Former Community Member
Not applicable

Can you please tell us a bit about why? What is the use case? If you could leverage this policy (https://cloud.google.com/apigee/docs/api-platform/reference/policies/oas-validation-policy) would you still need access to the raw contents?

Hi Srinandan, I have a logging shared flow in my post client flowhook that is common to all of my proxies. I'm planning to log the request path for the proxy endpoint that was accessed. I know we have apigee flow variables we can use, but I cannot use any of available flow variables to get the aggregated metrics for the endpoints that has path parameters- I've done a workaroud to avoid having query params and host content from "request.uri" flow variable tho. So, I'm planning to read the paths in the OAS from the sharedflow's javascript policy and try to match the "request.uri" and use the oas path to log in case of match. srinandans@googleSai Saran VaidyanathanDino-at-Google

Today it is not possible to retrieve the text of the openapi resources from within a proxy (or sharedflow). There is an open feature request to allow that. ref: b/155436526

I have no status on whether that FR will be accepted or... if it is accepted, when it will become available.

So... for now you must .... use a workaround. Perhaps embed the spec redundantly, in 2 places in the API proxy.... and that would allow you to get what you want.

Not applicable

you can use java callout for the same.Inside java callout, you can parse the oas in your code and then create a jar.