Module: Svelte

Defined in:
lib/svelte.rb,
lib/svelte/path.rb,
lib/svelte/service.rb,
lib/svelte/version.rb,
lib/svelte/operation.rb,
lib/svelte/rest_client.rb,
lib/svelte/path_builder.rb,
lib/svelte/configuration.rb,
lib/svelte/model_factory.rb,
lib/svelte/swagger_builder.rb,
lib/svelte/errors/http_error.rb,
lib/svelte/errors/json_error.rb,
lib/svelte/generic_operation.rb,
lib/svelte/operation_builder.rb,
lib/svelte/string_manipulator.rb,
lib/svelte/errors/version_error.rb,
lib/svelte/errors/parameter_error.rb,
lib/svelte/model_factory/parameter.rb

Overview

Svelte is a sleek Ruby API Client generated from a Swagger spec.

You can hand it a spec which defines an path like /api/comments/{id} that supports a series of operations like get, post, delete, and a module name you want built (i.e. Comments), and it will hand you a Svelte::Service::Comments object that can be used like so:

Examples:

Svelte::Service::Comments::Api::Comments.get_comment_by_id(id: 10)
Svelte::Service::Comments::Api::Comments.create_comment(contents: 'nice post!')
Svelte::Service::Comments::Api::Comments.delete_comment_by_id(id: 10)

Defined Under Namespace

Modules: ModelFactory, StringManipulator Classes: Configuration, GenericOperation, HTTPError, JSONError, Operation, OperationBuilder, ParameterError, Path, PathBuilder, RestClient, Service, SwaggerBuilder, VersionError

Constant Summary collapse

VERSION =

Version

'0.3.0'

Class Method Summary collapse

Class Method Details

.create(url: nil, json: nil, module_name:, options: {}) ⇒ Object

Note:

Either url or json need to be provided. url will take precedence over json

Parameters:

  • url (String) (defaults to: nil)

    url pointing to a Swagger spec

  • json (String) (defaults to: nil)

    the entire Swagger spec as a String

  • module_name (String)

    constant name where you want Svelte to build the new functionality on top of

  • options (Hash) (defaults to: {})

    configuration options when making HTTP requests Supported values are: :auth [Hash] either { token: "value" } or { basic: { username: "value", password: "value" }} :headers [Hash] HTTP request headers :host [String] overrides the "host" value in the Swagger spec :base_path [String] overrides the "basePath" value in the Swagger spec :protocol [String] overrides the network protocol used (defaults to "http")



43
44
45
# File 'lib/svelte.rb', line 43

def self.create(url: nil, json: nil, module_name:, options: {})
  Service.create(url: url, json: json, module_name: module_name, options: options)
end