Module: GrapeSwagger::SwaggerDocumentationAdder
- Includes:
- SwaggerRouting
- Defined in:
- lib/grape-swagger/swagger_documentation_adder.rb
Instance Attribute Summary collapse
-
#combined_namespace_routes ⇒ Object
Returns the value of attribute combined_namespace_routes.
-
#combined_namespaces ⇒ Object
Returns the value of attribute combined_namespaces.
-
#combined_routes ⇒ Object
Returns the value of attribute combined_routes.
Instance Method Summary collapse
Instance Attribute Details
#combined_namespace_routes ⇒ Object
Returns the value of attribute combined_namespace_routes.
7 8 9 |
# File 'lib/grape-swagger/swagger_documentation_adder.rb', line 7 def combined_namespace_routes @combined_namespace_routes end |
#combined_namespaces ⇒ Object
Returns the value of attribute combined_namespaces.
7 8 9 |
# File 'lib/grape-swagger/swagger_documentation_adder.rb', line 7 def combined_namespaces @combined_namespaces end |
#combined_routes ⇒ Object
Returns the value of attribute combined_routes.
7 8 9 |
# File 'lib/grape-swagger/swagger_documentation_adder.rb', line 7 def combined_routes @combined_routes end |
Instance Method Details
#add_swagger_documentation(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/grape-swagger/swagger_documentation_adder.rb', line 11 def add_swagger_documentation( = {}) documentation_class = create_documentation_class version_for() = { target_class: self }.merge() @target_class = [:target_class] auth_wrapper = [:endpoint_auth_wrapper] || Class.new use auth_wrapper if auth_wrapper.method_defined?(:before) && !middleware.flatten.include?(auth_wrapper) documentation_class.setup() mount(documentation_class) combined_routes = combine_routes(@target_class, documentation_class) combined_namespaces = combine_namespaces(@target_class) combined_namespace_routes = combine_namespace_routes(combined_namespaces, combined_routes) exclusive_route_keys = combined_routes.keys - combined_namespaces.keys @target_class.combined_namespace_routes = combined_namespace_routes.merge( combined_routes.slice(*exclusive_route_keys) ) @target_class.combined_routes = combined_routes @target_class.combined_namespaces = combined_namespaces documentation_class end |