securedBy coming from uses is not generating user/password client
ca-stefan-cordes opened this issue · 2 comments
Describe the bug
Having a raml file with
uses:
candaCommons: exchange_modules/6b05fd51-2fe5-4078-b1a1-83d16894bf76/canda-commons/1.0.8/canda-commons.raml
securedBy: [candaCommons.basicAuth]
with canda-commons.raml
securitySchemes:
basicAuth:
displayName: Basic Authentication
description: This API supports Basic Authentication. The client has to provide an "Authorization" header with valid credentials.
type: Basic Authentication
describedBy:
headers:
Authorization:
description: Used to send valid credentials.
type: string
responses:
401:
description: Credentials are missing or could not be validated by the server.
creates an Client without authentication while
securitySchemes:
clientid:
type: Basic Authentication
securedBy: [clientid]
To Reproduce
Steps to reproduce the behavior:
- Generate from above raml
- See public MuletemplateClient(String baseUrl) { generated.
Expected behavior
public MuletemplateClient(java.lang.String baseUrl, java.lang.String username, java.lang.String password) {
should be generated.
Screenshots
Desktop (please complete the following information):
- OS: Windows
- raml-java-client-generator: 0.9
Smartphone (please complete the following information):
Additional context
Looks like the problem is that generator is looking for securitySchemes only (which are empty on root level in case they come from library):
path "securitySchemes" (id=239)
from org.raml.v2.internal.impl.commons.nodes.RamlDocumentNode (id=262)
but path is uses/*/
Thread [main] (Suspended) org.raml.yagi.framework.util.NodeSelector.selectFrom(java.lang.String, org.raml.yagi.framework.nodes.Node) line: 53 org.raml.yagi.framework.model.ModelProxyBuilder$SimpleProxy.fromNodeKey(java.lang.reflect.Method, java.lang.reflect.Type) line: 88 org.raml.yagi.framework.model.ModelProxyBuilder$SimpleProxy.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) line: 70 com.sun.proxy.$Proxy7.securitySchemes() line: not available org.mule.raml.impl.v10.model.ApiModelImpl.getSecuritySchemes() line: 115
Adding Security Schemes from "getSecuredBy" looks like the solution.
Thanks for the PR, it is ready to be consumed on the 0.11 version