class ReeSwagger::BuildSchema

def call(title:, description:, version:, api_url:, endpoints:)

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