Class: DryCrudJsonapiSwagger::Setup

Inherits:
Object
  • Object
show all
Defined in:
app/domain/dry_crud_jsonapi_swagger/setup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_url, controller_classes) ⇒ Setup

Returns a new instance of Setup.



5
6
7
8
# File 'app/domain/dry_crud_jsonapi_swagger/setup.rb', line 5

def initialize(request_url, controller_classes)
  @request_uri = URI.parse(request_url)
  @controller_classes = controller_classes
end

Instance Attribute Details

#controller_classesObject (readonly)

Returns the value of attribute controller_classes.



3
4
5
# File 'app/domain/dry_crud_jsonapi_swagger/setup.rb', line 3

def controller_classes
  @controller_classes
end

#request_uriObject (readonly)

Returns the value of attribute request_uri.



3
4
5
# File 'app/domain/dry_crud_jsonapi_swagger/setup.rb', line 3

def request_uri
  @request_uri
end

Instance Method Details

#hostObject



15
16
17
# File 'app/domain/dry_crud_jsonapi_swagger/setup.rb', line 15

def host
  "#{request_uri.host}:#{request_uri.port}"
end

#json_api_mimetypeObject



19
20
21
# File 'app/domain/dry_crud_jsonapi_swagger/setup.rb', line 19

def json_api_mimetype
  JSONAPI::Rails::Railtie::MEDIA_TYPE
end

#runObject



10
11
12
13
# File 'app/domain/dry_crud_jsonapi_swagger/setup.rb', line 10

def run
  swaggered_classes = [, setup_controllers, setup_models].flatten
  Swagger::Blocks.build_root_json(swaggered_classes)
end

#setup_tags(swagger_doc) ⇒ Object



23
24
25
# File 'app/domain/dry_crud_jsonapi_swagger/setup.rb', line 23

def setup_tags(swagger_doc)
  TagsSetup.new(swagger_doc).run
end