Module: Apigen::Formats::OpenAPI::V3

Extended by:
JsonBase
Defined in:
lib/apigen/formats/openapi.rb

Overview

OpenAPI 3 generator.

Class Method Summary collapse

Class Method Details

.generate(api) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/apigen/formats/openapi.rb', line 15

def generate(api)
  # TODO: Allow overriding any of the hardcoded elements.
  {
    'openapi' => '3.0.0',
    'info' => {
      'version' => '1.0.0',
      'title' => 'API',
      'description' => api.description,
      'termsOfService' => '',
      'contact' => {
        'name' => ''
      },
      'license' => {
        'name' => ''
      }
    },
    'servers' => [
      {
        'url' => 'http://localhost'
      }
    ],
    'paths' => paths(api),
    'components' => {
      'schemas' => definitions(api)
    }
  }.to_yaml
end