raml-java-parser
raml-java-parser copied to clipboard
ClassCastException when trying to cast to OAuth2SecuritySchemeSettings in 0.8 (parser-1.0.8)
There is currently no way to get the OAuth2SecuritySchemeSettings for an oauth scheme because the interface SecuritySchemeSettings has no methods.
Trying to cast SecuritySchemeSettings to OAuth2SecuritySchemeSettings gives a ClassCastException because it is a java.lang.Proxy.
The workaround is to unwrap the proxy:
java.lang.reflect.Method method = OAuth2SecuritySchemeSettings.class.getMethod("authorizationUri");
InvocationHandler handler = Proxy.getInvocationHandler(settings);
FixedUri uri = (FixedUri) handler.invoke(settings, method, new Object[0]);
Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-92