Class: AnotherApi::OpenAPI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/another_api/openapi/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/another_api/openapi/configuration.rb', line 18

def initialize
  @title = "API"
  @description = nil
  @version = "1.0.0"
  @path_prefix = ""

  # Empty string means "no namespace stripping": every ApiSerializer::Schema
  # subclass referenced via api_action(schema:) is included, but no
  # ObjectSpace auto-discovery happens. Set to a string like
  # "MyApp::Schemas::V1::" to opt into auto-discovery of nested schemas.
  @schema_namespace_prefix = ""

  @default_variant_name = :full
  @additional_discovery_variants = [:minimal]

  @controllers_glob = "app/controllers/**/*_controller.rb"
  @eager_load_controllers = true

  # Paths under Rails.root that SpecRenderer watches for mtime changes
  # to invalidate its dev-mode cache.
  @watched_dirs = ["app/controllers"]

  @info_extra = {}
  @servers = nil

  @security_schemes = AnotherApi::OpenAPI::CommonSchemas.default_security_schemes
  @security = [{bearerAuth: []}]

  @common_parameters = AnotherApi::OpenAPI::CommonSchemas.default_parameters
  @pagination_metadata_schema = AnotherApi::OpenAPI::CommonSchemas.
  @filter_expression_schema = {type: "string", description: "Filter expression. See API documentation for syntax."}
  @error_response_content = AnotherApi::OpenAPI::CommonSchemas.default_error_response

  # Default concerns shipped with another_api. Users can register their
  # own app-level concern modules with #register_concern.
  @concern_map = {
    "AnotherApi::Paginated" => :paginated,
    "AnotherApi::FilteredAndSorted" => :filtered_and_sorted,
    "AnotherApi::SchemaConfigurable" => :schema_configurable
  }
end

Instance Attribute Details

#additional_discovery_variantsObject

Returns the value of attribute additional_discovery_variants.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def additional_discovery_variants
  @additional_discovery_variants
end

#common_parametersObject

Returns the value of attribute common_parameters.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def common_parameters
  @common_parameters
end

#concern_mapObject (readonly)

Returns the value of attribute concern_map.



16
17
18
# File 'lib/another_api/openapi/configuration.rb', line 16

def concern_map
  @concern_map
end

#controllers_globObject

Returns the value of attribute controllers_glob.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def controllers_glob
  @controllers_glob
end

#default_variant_nameObject

Returns the value of attribute default_variant_name.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def default_variant_name
  @default_variant_name
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def description
  @description
end

#eager_load_controllersObject

Returns the value of attribute eager_load_controllers.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def eager_load_controllers
  @eager_load_controllers
end

#error_response_contentObject

Returns the value of attribute error_response_content.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def error_response_content
  @error_response_content
end

#filter_expression_schemaObject

Returns the value of attribute filter_expression_schema.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def filter_expression_schema
  @filter_expression_schema
end

#info_extraObject

Returns the value of attribute info_extra.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def info_extra
  @info_extra
end

#pagination_metadata_schemaObject

Returns the value of attribute pagination_metadata_schema.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def 
  @pagination_metadata_schema
end

#path_prefixObject

Returns the value of attribute path_prefix.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def path_prefix
  @path_prefix
end

#schema_namespace_prefixObject

Returns the value of attribute schema_namespace_prefix.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def schema_namespace_prefix
  @schema_namespace_prefix
end

#securityObject

Returns the value of attribute security.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def security
  @security
end

#security_schemesObject

Returns the value of attribute security_schemes.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def security_schemes
  @security_schemes
end

#serversObject

Returns the value of attribute servers.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def servers
  @servers
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def title
  @title
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def version
  @version
end

#watched_dirsObject

Returns the value of attribute watched_dirs.



6
7
8
# File 'lib/another_api/openapi/configuration.rb', line 6

def watched_dirs
  @watched_dirs
end

Instance Method Details

#register_concern(module_name, key) ⇒ Object



60
61
62
# File 'lib/another_api/openapi/configuration.rb', line 60

def register_concern(module_name, key)
  @concern_map = @concern_map.merge(module_name.to_s => key.to_sym)
end