Class: DryOpenApi::Specification

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Includes:
EquatableAsContent
Defined in:
lib/dry_open_api/specification.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EquatableAsContent

#==

Class Method Details

.load(hash) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dry_open_api/specification.rb', line 30

def self.load(hash)
  return unless hash

  new(
    openapi: hash['openapi'],
    info: Info.load(hash['info']),
    paths: Paths.load(hash['paths']),
    components: Components.load(hash['components']),
    security: hash['security']&.map { |requirement_hash| SecurityRequirement.load(requirement_hash) },
    tags: hash['tags']&.map { |tag_hash| Tag.load(tag_hash) },
    external_docs: ExternalDocumentation.load(hash['externalDocs'])
  )
end

Instance Method Details

#serializable_hashObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dry_open_api/specification.rb', line 18

def serializable_hash
  {
    'openapi' => openapi,
    'info' => info.serializable_hash,
    'paths' => paths.serializable_hash,
    'components' => components&.serializable_hash,
    'security' => security&.map(&:serializable_hash),
    'tags' => tags&.map(&:serializable_hash),
    'externalDocs' => external_docs&.serializable_hash
  }.compact
end