Module: Apigen::Formats::Swagger::V2

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

Overview

Swagger 2 (aka OpenAPI 2) 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
# File 'lib/apigen/formats/swagger.rb', line 15

def generate(api)
  # TODO: Allow overriding any of the hardcoded elements.
  {
    'swagger' => '2.0',
    'info' => info(api),
    'host' => 'localhost',
    'basePath' => '/',
    'schemes' => %w[
      http
      https
    ],
    'consumes' => [
      'application/json'
    ],
    'produces' => [
      'application/json'
    ],
    'paths' => paths(api),
    'definitions' => definitions(api)
  }.to_yaml
end