Sha256: 3af06068ae2a65a5db98ed88e09f7c24e0839550f410d3886f777246366350c1

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'sober_swag'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
module Types
  include Dry.Types()
end

Bio = SoberSwag.input_object do
  attribute :name, primitive(:String).meta(description: 'A very basic bio name')
end

Person = SoberSwag.input_object do
  attribute :name, primitive(:String).meta(description: 'The full name description')
  attribute :age, param(:Integer).constrained(gt: 0).optional.meta(description: 'My cool age')
  attribute? :mood, Types::String
end

##
# Demonstration of subclass-style.
class PersonSearch < SoberSwag::InputObject
  attribute? :name, Types::String
  attribute? :age, Types::Integer
end

##
# Demonstration of subclass-style *and* recursion in structs.
class LinkedList < SoberSwag::InputObject
  attribute :value, Types::String
  attribute? :next, LinkedList
end

Foo = SoberSwag::OutputObject.define do
  field :name, primitive(:String)
  field :age, primitive(:String)

  view :foo do
    field :bar, primitive(:String).optional
  end
end

# (If you use this, don't forget to add pry to your Gemfile!)
require 'pry'
Pry.start

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sober_swag-0.12.0 bin/console
sober_swag-0.11.0 bin/console
sober_swag-0.10.0 bin/console
sober_swag-0.9.0 bin/console
sober_swag-0.8.0 bin/console
sober_swag-0.7.0 bin/console