Skip to content
forked from Manfred/Reynard

Minimal OpenAPI client for Ruby.

License

Notifications You must be signed in to change notification settings

LuukBosch/Reynard

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reynard

Reynard is an OpenAPI client for Ruby. It operates directly on the OpenAPI specification without the need to generate any source code.

# A Client does not have a fixed state and creating a new
# client will never incur a cost over creating the object
# itself.
reynard = Reynard.new(filename: 'openapi.yml')

Installing

Reynard is distributed as a gem called reynard.

Choosing a server

An OpenAPI specification may specify multiple servers. There is no automated way to select the ‘correct’ server so Reynard uses the first one by default.

For example:

servers:
  - url: http://production.example.com/v1
  - url: http://staging.example.com/v1

Will cause Reynard to choose the production URL.

reynard.url #=> "http://production.example.com/v1"

You can override the base_url if you want to use a different one.

reynard.base_url('http://test.example.com/v1')

You also have access to all servers in the specification so you can automatically select one however you want.

base_url = @reynard.servers.map(&:url).find do |url|
  /staging/.match(url)
end
reynard.base_url(base_url)

Calling endpoints

Assuming there is an operation called employeeByUuid you can it as shown below.

employee = reynard.
  operation('employeeByUuid').
  params(uuid: uuid).
  execute

When an operation requires a body, you can add it as structured data.

employee = reynard.
  operation('createEmployee').
  body(name: 'Sam Seven').
  execute

Copyright and other legal

See LICENCE.

About

Minimal OpenAPI client for Ruby.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%