diff --git a/app/helpers/swagger_ui_engine/config_parser.rb b/app/helpers/swagger_ui_engine/config_parser.rb index 8a379bf..512f783 100644 --- a/app/helpers/swagger_ui_engine/config_parser.rb +++ b/app/helpers/swagger_ui_engine/config_parser.rb @@ -1,10 +1,9 @@ module SwaggerUiEngine module ConfigParser SwaggerUiEngine::DEFAULTS.each do |default| - config_name = default.first.to_s - next if config_name == 'validator_url' - - define_method("set_#{config_name}") do + next if default.first.to_s == 'validator_url' + + define_method("set_#{default.first}") do # set_swagger_url set_doc_expansion # set_json_editor set_model_rendering # set_request_headers diff --git a/app/helpers/swagger_ui_engine/oauth_config_parser.rb b/app/helpers/swagger_ui_engine/oauth_config_parser.rb index 7a21c34..4960044 100644 --- a/app/helpers/swagger_ui_engine/oauth_config_parser.rb +++ b/app/helpers/swagger_ui_engine/oauth_config_parser.rb @@ -1,31 +1,12 @@ module SwaggerUiEngine module OauthConfigParser - def set_oauth_app_name - configuration.oauth_app_name || 'your-app-name' - end - - def set_oauth_client_id - configuration.oauth_client_id || 'your-client-id' - end - - def set_oauth_client_secret - configuration.oauth_client_secret || 'your-client-secret-if-required' - end - - def set_oauth_realm - configuration.oauth_realm || 'your-realms' - end - - def set_oauth_scope_separator - configuration.oauth_scope_separator || ' ' - end - - def set_oauth_query_string_params - configuration.oauth_query_string_params || {} - end - - def configuration - SwaggerUiEngine.configuration + SwaggerUiEngine::OAUTH2_DEFAULTS.each do |default| + define_method("set_#{default.first}") do + # set_oauth_app_name set_oauth_client_id + # set_oauth_client_secret set_oauth_realm + # set_oauth_scope_separator set_oauth_query_string_params + configuration.send("#{default.first}") || default.last + end end end end diff --git a/lib/swagger_ui_engine/defaults.rb b/lib/swagger_ui_engine/defaults.rb index 1cf0bcc..0c4d193 100644 --- a/lib/swagger_ui_engine/defaults.rb +++ b/lib/swagger_ui_engine/defaults.rb @@ -7,4 +7,13 @@ module SwaggerUiEngine request_headers: false, validator_url: '//online.swagger.io/validator' }.freeze + + OAUTH2_DEFAULTS = { + oauth_app_name: 'your-app-name', + oauth_client_id: 'your-client-id', + oauth_client_secret: 'your-client-secret-if-required', + oauth_realm: 'your-realms', + oauth_scope_separator: ' ', + oauth_query_string_params: {} + }.freeze end