Skip to content

Commit

Permalink
fixes #114 server info scope injection only works with clientCredenti…
Browse files Browse the repository at this point in the history
…als grant flow
  • Loading branch information
stevehu committed Mar 11, 2018
1 parent ec46151 commit 44f3202
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep
Any anyComponents = ((Any)model).get("components");
if(anyComponents.valueType() != ValueType.INVALID) {
Any schemas = anyComponents.asMap().get("schemas");
if(schemas.valueType() != ValueType.INVALID) {
if(schemas != null && schemas.valueType() != ValueType.INVALID) {
for(Map.Entry<String, Any> entry : schemas.asMap().entrySet()) {
List<Map<String, Any>> props = new ArrayList<>();
String key = entry.getKey();
Expand Down Expand Up @@ -317,12 +317,15 @@ public void injectEndpoints(Object model) {
if(def != null && "oauth2".equals(def.get("type").toString())) {
authName = name;
Map<String, Any> flows = def.get("flows").asMap();
Map<String, Any> ccMap = flows.get("clientCredentials").asMap();
Any scopes = ccMap.get("scopes");
if(scopes != null) {
scopes.asMap().put("server.info.r", Any.wrap("read server info"));
for(Map.Entry<String, Any> entry: flows.entrySet()) {
Map<String, Any> oauthMap = entry.getValue().asMap();
if(oauthMap != null) {
Any scopes = oauthMap.get("scopes");
if(scopes != null) {
scopes.asMap().put("server.info.r", Any.wrap("read server info"));
}
}
}
break;
}
}
}
Expand Down

0 comments on commit 44f3202

Please sign in to comment.