Sha256: 9153a77194bf4843b8ead348819ed042b1a3ea3473efe2b5bb0a1b0c116b95d6

Contents?: true

Size: 933 Bytes

Versions: 1

Compression:

Stored size: 933 Bytes

Contents

require 'swagger/swagger_object'
require 'swagger/v2/operation'

module Swagger
  module V2
    # Class representing a Swagger "Path Item Object".
    # @see https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#pathItemObject Path Item Object
    class Path < SwaggerObject
      extend Forwardable
      def_delegator :parent, :host

      VERBS = [:get, :put, :post, :delete, :options, :head, :patch]
      VERBS.each do | verb |
        field verb, Operation
      end
      field :parameters, Array[Parameter]

      def initialize(hash)
        hash[:parameters] ||= []
        super
      end

      def operations
        VERBS.each_with_object({}) do | v, h |
          operation = send v
          h[v] = operation if operation
        end
      end

      def uri_template
        "#{parent.host}#{parent.base_path}#{path}"
      end

      def path
        parent.paths.key self
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swagger-core-0.2.1 lib/swagger/v2/path.rb