Sha256: a590e65964bba9eddf7c15fb1faa514b10cbca9f10a39eb3b7d9baa0d9124480

Contents?: true

Size: 898 Bytes

Versions: 114

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

class ReeSwagger::BuildSchema
  include Ree::FnDSL

  fn :build_schema do
    link :build_endpoint_schema
    link 'ree_swagger/dto/endpoint_dto', -> { EndpointDto }
  end

  contract(String, String, String, String, ArrayOf[EndpointDto] => Hash)
  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
end

Version data entries

114 entries across 114 versions & 1 rubygems

Version Path
ree_lib-1.0.64 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.63 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.62 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.61 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.60 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.59 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.58 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.57 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.56 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.55 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.54 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.53 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.52 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.51 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.50 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.49 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.48 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.47 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.46 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb
ree_lib-1.0.45 lib/ree_lib/packages/ree_swagger/package/ree_swagger/functions/build_schema.rb