Class: OpenApiDocumentation::Path
- Inherits:
-
Object
- Object
- OpenApiDocumentation::Path
- Defined in:
- lib/apiculture/openapi_documentation.rb
Constant Summary collapse
- VERBS_WITHOUT_BODY =
%w(get head delete options)
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(path, prefix, app) ⇒ Path
constructor
A new instance of Path.
- #name ⇒ Object
Constructor Details
#initialize(path, prefix, app) ⇒ Path
Returns a new instance of Path.
59 60 61 |
# File 'lib/apiculture/openapi_documentation.rb', line 59 def initialize(path, prefix, app) @path, @prefix, @app = path, prefix, app end |
Instance Method Details
#build ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/apiculture/openapi_documentation.rb', line 63 def build request_body = build_request_body unless VERBS_WITHOUT_BODY.include?(@path.http_verb) { name => { @path.http_verb.to_sym => { summary: @path.description, description: @path.description, tags: [ @app.to_s ], parameters: build_parameters, requestBody: request_body, responses: build_responses, operationId: operation_id }.delete_if { |_k, v| v.nil? || v.empty? } } } end |
#name ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/apiculture/openapi_documentation.rb', line 81 def name full_path = @path.path.to_s @path.route_parameters.each do |parameter| # This is a bit confusing but naming is a little different between # apiculture and openapi full_path.gsub!(":#{parameter.name}", "\{#{parameter.name}\}") end Util.clean_path("#{@prefix}#{full_path}") end |