Skip to content

Commit

Permalink
fix: add scope prefix to available scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
ikadix committed Sep 3, 2024
1 parent b07d33a commit 462b004
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/apia/open_api/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ def add_paths
end
end

def build_scope_map
def build_scope_map(scope_prefix)
scopes = {}

@api.definition.route_set.routes.each do |route|
next unless route.group.nil? || route.group.schema?
next unless route.endpoint.definition.schema?

route.endpoint.definition.scopes.each do |scope|
scopes[scope] = ""
scopes["#{scope_prefix}#{scope}"] = ""
end
end

Expand Down Expand Up @@ -190,7 +190,7 @@ def add_additional_security_schemes(security_schemes)
value = JSON.parse(value.to_json, symbolize_names: true)

if value[:type] == "oauth2" && value[:flows].key?(:authorizationCode)
value[:flows][:authorizationCode][:scopes] = build_scope_map
value[:flows][:authorizationCode][:scopes] = build_scope_map(value[:"x-scope-prefix"])
end

@spec[:components][:securitySchemes][key] = value
Expand Down

0 comments on commit 462b004

Please sign in to comment.