Class: OasCore::Spec::Specification

Inherits:
Object
  • Object
show all
Includes:
Specable
Defined in:
lib/oas_core/spec/specification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Specable

#as_json, #to_spec

Constructor Details

#initializeSpecification

Returns a new instance of Specification.



11
12
13
14
15
16
17
18
19
# File 'lib/oas_core/spec/specification.rb', line 11

def initialize
  @components = Components.new(self)
  @info = OasCore.config.info
  @openapi = '3.1.0'
  @servers = OasCore.config.servers
  @tags = OasCore.config.tags
  @external_docs = {}
  @paths = Spec::Paths.new(self)
end

Instance Attribute Details

#componentsObject

Returns the value of attribute components.



9
10
11
# File 'lib/oas_core/spec/specification.rb', line 9

def components
  @components
end

#external_docsObject

Returns the value of attribute external_docs.



9
10
11
# File 'lib/oas_core/spec/specification.rb', line 9

def external_docs
  @external_docs
end

#infoObject

Returns the value of attribute info.



9
10
11
# File 'lib/oas_core/spec/specification.rb', line 9

def info
  @info
end

#openapiObject

Returns the value of attribute openapi.



9
10
11
# File 'lib/oas_core/spec/specification.rb', line 9

def openapi
  @openapi
end

#pathsObject

Returns the value of attribute paths.



9
10
11
# File 'lib/oas_core/spec/specification.rb', line 9

def paths
  @paths
end

#serversObject

Returns the value of attribute servers.



9
10
11
# File 'lib/oas_core/spec/specification.rb', line 9

def servers
  @servers
end

#tagsObject

Returns the value of attribute tags.



9
10
11
# File 'lib/oas_core/spec/specification.rb', line 9

def tags
  @tags
end

Instance Method Details

#oas_fieldsObject



21
22
23
# File 'lib/oas_core/spec/specification.rb', line 21

def oas_fields
  %i[openapi info servers paths components security tags external_docs]
end

#securityObject

Create the Security Requirement Object.



27
28
29
30
31
# File 'lib/oas_core/spec/specification.rb', line 27

def security
  return [] unless OasCore.config.authenticate_all_routes_by_default

  OasCore.config.security_schemas.map { |key, _| { key => [] } }
end