Class: ReeSwagger::BuildSchema

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb

Instance Method Summary collapse

Instance Method Details

#call(title:, description:, version:, api_url:, endpoints:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb', line 12

def call(title:, description:, version:, api_url:, endpoints:)
  {
    openapi: "3.0.0",
    info: {
      title:       title,
      description: description,
      version:     version
    },
    components: {
      securitySchemes: {
        ApiKeyAuth: {
          type: 'apiKey',
          in: 'header',
          name: 'Authorization'
        }
      }
    },
    servers: [{ url: api_url }],
    paths: endpoints.each_with_object(Hash.new { _1[_2] = {} }) {
      path_dto = build_endpoint_schema(_1)
      _2[path_dto.path].merge!(path_dto.schema)
    }
  }
end