Class: OasCore::Spec::Info

Inherits:
Object
  • Object
show all
Includes:
Specable
Defined in:
lib/oas_core/spec/info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Specable

#as_json, #to_spec

Constructor Details

#initialize(**kwargs) ⇒ Info

Returns a new instance of Info.



9
10
11
12
13
14
15
16
17
# File 'lib/oas_core/spec/info.rb', line 9

def initialize(**kwargs)
  @title = kwargs[:title] || default_title
  @summary = kwargs[:summary] || default_summary
  @description = kwargs[:description] || default_description
  @terms_of_service = kwargs[:terms_of_service] || ''
  @contact = Spec::Contact.new
  @license = Spec::License.new
  @version = kwargs[:version] || '0.0.1'
end

Instance Attribute Details

#contactObject

Returns the value of attribute contact.



7
8
9
# File 'lib/oas_core/spec/info.rb', line 7

def contact
  @contact
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/oas_core/spec/info.rb', line 7

def description
  @description
end

#licenseObject

Returns the value of attribute license.



7
8
9
# File 'lib/oas_core/spec/info.rb', line 7

def license
  @license
end

#summaryObject

Returns the value of attribute summary.



7
8
9
# File 'lib/oas_core/spec/info.rb', line 7

def summary
  @summary
end

#terms_of_serviceObject

Returns the value of attribute terms_of_service.



7
8
9
# File 'lib/oas_core/spec/info.rb', line 7

def terms_of_service
  @terms_of_service
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/oas_core/spec/info.rb', line 7

def title
  @title
end

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/oas_core/spec/info.rb', line 7

def version
  @version
end

Instance Method Details

#default_descriptionObject



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
59
60
61
62
63
64
65
# File 'lib/oas_core/spec/info.rb', line 31

def default_description
  "# Welcome to OasCore

OasCore automatically generates interactive documentation for your Rails APIs using the OpenAPI Specification 3.1 (OAS 3.1) and displays it with a nice UI.

## Getting Started

You've successfully mounted the OasCore engine. This default documentation is based on your routes and automatically gathered information.

## Enhancing Your Documentation

To customize and enrich your API documentation:

1. Generate an initializer file:

  ```
  rails generate oas_core:config
  ```
2. Edit the created `config/initializers/oas_core.rb` file to override default settings and add project-specific information.

3. Use Yard tags in your controller methods to provide detailed API endpoint descriptions.

## Features

- Automatic OAS 3.1 document generation
- [RapiDoc](https://github.com/rapi-doc/RapiDoc) integration for interactive exploration
- Minimal setup required for basic documentation
- Extensible through configuration and Yard tags

Explore your API documentation and enjoy the power of OasCore!

For more information and advanced usage, visit the [OasCore GitHub repository](https://github.com/a-chacon/oas_core).

"
end

#default_summaryObject



27
28
29
# File 'lib/oas_core/spec/info.rb', line 27

def default_summary
  'OasCore: Automatic Interactive API Documentation for Rails'
end

#default_titleObject



23
24
25
# File 'lib/oas_core/spec/info.rb', line 23

def default_title
  "OasCore #{VERSION}"
end

#oas_fieldsObject



19
20
21
# File 'lib/oas_core/spec/info.rb', line 19

def oas_fields
  %i[title summary description terms_of_service contact license version]
end