Class: GrapeOAS::Exporter::OAS3Schema

Inherits:
Object
  • Object
show all
Includes:
Concerns::SchemaIndexer, Concerns::TagBuilder
Defined in:
lib/grape_oas/exporter/oas3_schema.rb

Direct Known Subclasses

OAS30Schema, OAS31Schema

Instance Method Summary collapse

Methods included from Concerns::SchemaIndexer

#build_schema_index, #collect_refs, #collect_schemas_from_operation, #find_schema_by_canonical_name, #index_schema, #schema_index

Methods included from Concerns::TagBuilder

#build_tags, #collect_used_tag_names, #normalize_tag

Constructor Details

#initialize(api_model:) ⇒ OAS3Schema

Returns a new instance of OAS3Schema.



9
10
11
12
13
# File 'lib/grape_oas/exporter/oas3_schema.rb', line 9

def initialize(api_model:)
  @api = api_model
  @ref_tracker = Set.new
  @ref_schemas = {}
end

Instance Method Details

#generateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/grape_oas/exporter/oas3_schema.rb', line 15

def generate
  {
    "openapi" => openapi_version,
    "info" => build_info,
    "servers" => build_servers,
    "tags" => build_tags,
    "paths" => OAS3::Paths.new(@api, @ref_tracker,
                               nullable_strategy: nullable_strategy,
                               suppress_default_error_response: @api.suppress_default_error_response,).build,
    "components" => build_components,
    "security" => build_security
  }.compact
end