Class: Skooma::Objects::OpenAPI

Inherits:
Base
  • Object
show all
Defined in:
lib/skooma/objects/openapi.rb,
lib/skooma/objects/openapi/keywords/info.rb,
lib/skooma/objects/openapi/keywords/paths.rb,
lib/skooma/objects/openapi/keywords/openapi.rb,
lib/skooma/objects/openapi/keywords/security.rb,
lib/skooma/objects/openapi/keywords/webhooks.rb,
lib/skooma/objects/openapi/keywords/components.rb,
lib/skooma/objects/openapi/keywords/json_schema_dialect.rb

Overview

OpenAPI Object – the root object of the OpenAPI document. spec.openapis.org/oas/v3.1.0#openapi-object

Defined Under Namespace

Modules: Keywords

Constant Summary

Constants inherited from Base

Base::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from ExternalRefs

#resolve_ref

Constructor Details

This class inherits a constructor from Skooma::Objects::Base

Instance Attribute Details

#json_schema_dialect_uriObject



66
67
68
# File 'lib/skooma/objects/openapi.rb', line 66

def json_schema_dialect_uri
  @json_schema_dialect_uri || parent_schema&.json_schema_dialect_uri
end

Instance Method Details

#bootstrap(value) ⇒ Object



24
25
26
27
28
# File 'lib/skooma/objects/openapi.rb', line 24

def bootstrap(value)
  # always evaluate openapi to check version,
  # and set metaschema_uri and json_schema_dialect_uri
  add_keyword(Keywords::OpenAPI.new(self, value["openapi"]))
end

#enforce_access_modes=(value) ⇒ Object

Raises:

  • (ArgumentError)


42
43
44
45
46
# File 'lib/skooma/objects/openapi.rb', line 42

def enforce_access_modes=(value)
  raise ArgumentError, "Enforce access modes must be a boolean" unless [true, false].include?(value)

  @enforce_access_modes = value
end

#enforce_access_modes?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/skooma/objects/openapi.rb', line 48

def enforce_access_modes?
  @enforce_access_modes
end

#evaluate(instance, result = nil) ⇒ Object



30
31
32
# File 'lib/skooma/objects/openapi.rb', line 30

def evaluate(instance, result = nil)
  super(Instance.new(instance), result)
end

#kw_classesObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/skooma/objects/openapi.rb', line 10

def kw_classes
  [
    Keywords::Info,
    Keywords::JSONSchemaDialect,
    Keywords::Paths,
    Keywords::Webhooks,
    Keywords::Components,
    Base::Keywords::Servers,
    Base::Keywords::Security,
    Base::Keywords::Tags,
    Skooma::Keywords::OAS31::Dialect::ExternalDocs
  ]
end

#path_prefixObject



62
63
64
# File 'lib/skooma/objects/openapi.rb', line 62

def path_prefix
  @path_prefix || ""
end

#path_prefix=(value) ⇒ Object

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
# File 'lib/skooma/objects/openapi.rb', line 34

def path_prefix=(value)
  raise ArgumentError, "Path prefix must be a string" unless value.is_a?(String)

  @path_prefix = value
  @path_prefix = "/#{@path_prefix}" unless @path_prefix.start_with?("/")
  @path_prefix = @path_prefix.delete_suffix("/") if @path_prefix.end_with?("/")
end

#use_patterns_for_path_matching=(value) ⇒ Object

Raises:

  • (ArgumentError)


52
53
54
55
56
# File 'lib/skooma/objects/openapi.rb', line 52

def use_patterns_for_path_matching=(value)
  raise ArgumentError, "Use patterns for path matching must be a boolean" unless [true, false].include?(value)

  @use_patterns_for_path_matching = value
end

#use_patterns_for_path_matching?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/skooma/objects/openapi.rb', line 58

def use_patterns_for_path_matching?
  @use_patterns_for_path_matching
end