Sha256: 8113a5d57579baf56bccf1df472ae2608bccf2b7baa43c1b3fbb38b646b39b90

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

#!/usr/bin/env ruby -W:no-experimental
# 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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sober_swag-0.5.0 bin/console
sober_swag-0.4.0 bin/console
sober_swag-0.3.0 bin/console
sober_swag-0.2.0 bin/console