Class: GrapeOAS::ApiModel::API

Inherits:
Node
  • Object
show all
Defined in:
lib/grape_oas/api_model/api.rb

Overview

Represents the root API object in the DTO model for OpenAPI v2/v3. Contains metadata, paths, servers, tags, and components. Used as the entry point for building OpenAPIv2 and OpenAPIv3 documents.

Constant Summary

Constants inherited from Node

Node::BUCKET_NAMES

Instance Attribute Summary collapse

Attributes inherited from Node

#id

Instance Method Summary collapse

Methods inherited from Node

bucket, #ref

Constructor Details

#initialize(title:, version:) ⇒ API

Returns a new instance of API.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/grape_oas/api_model/api.rb', line 16

def initialize(title:, version:)
  super()
  @title      = title
  @version    = version
  @paths      = Set.new
  @servers    = []
  @tag_defs   = Set.new
  @components = {}
  @host       = nil
  @base_path  = nil
  @schemes    = []
  @security_definitions = {}
  @security = []
  @registered_schemas = []
  @suppress_default_error_response = false
  @nullable_strategy = nil
end

Instance Attribute Details

#base_pathObject

Returns the value of attribute base_path.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def base_path
  @base_path
end

#componentsObject

Returns the value of attribute components.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def components
  @components
end

#hostObject

Returns the value of attribute host.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def host
  @host
end

#nullable_strategyObject

Returns the value of attribute nullable_strategy.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def nullable_strategy
  @nullable_strategy
end

#pathsObject

Returns the value of attribute paths.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def paths
  @paths
end

#registered_schemasObject

Returns the value of attribute registered_schemas.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def registered_schemas
  @registered_schemas
end

#schemesObject

Returns the value of attribute schemes.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def schemes
  @schemes
end

#securityObject

Returns the value of attribute security.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def security
  @security
end

#security_definitionsObject

Returns the value of attribute security_definitions.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def security_definitions
  @security_definitions
end

#serversObject

Returns the value of attribute servers.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def servers
  @servers
end

#suppress_default_error_responseObject

Returns the value of attribute suppress_default_error_response.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def suppress_default_error_response
  @suppress_default_error_response
end

#tag_defsObject

Returns the value of attribute tag_defs.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def tag_defs
  @tag_defs
end

#titleObject

Returns the value of attribute title.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def title
  @title
end

#versionObject

Returns the value of attribute version.



12
13
14
# File 'lib/grape_oas/api_model/api.rb', line 12

def version
  @version
end

Instance Method Details

#add_path(path) ⇒ Object



34
35
36
# File 'lib/grape_oas/api_model/api.rb', line 34

def add_path(path)
  @paths << path
end

#add_tags(*tags) ⇒ Object



38
39
40
# File 'lib/grape_oas/api_model/api.rb', line 38

def add_tags(*tags)
  @tag_defs.merge(tags)
end

#builder_cacheObject



42
43
44
# File 'lib/grape_oas/api_model/api.rb', line 42

def builder_cache
  @builder_cache ||= {}
end