Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI repair tool #287

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

Rake.add_rakelib 'lib/tasks'

task default: :spec

task :console do
Expand Down
3 changes: 0 additions & 3 deletions lib/ioki/model/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module Ioki
module Model
module Driver
class Base < Ioki::Model::Base
def self.specification_scope
'driver_api'
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/driver/monthly_tip_sum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Driver
class MonthlyTipSum < Base
def self.schema_path
'driver_api--tip_sum'
end

attribute :type, on: :read, type: :string
attribute :date, on: :read, type: :string
attribute :amount, on: :read, type: :object, class_name: 'Money'
Expand Down
3 changes: 0 additions & 3 deletions lib/ioki/model/passenger/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module Ioki
module Model
module Passenger
class Base < Ioki::Model::Base
def self.specification_scope
'passenger_api'
end
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions lib/ioki/model/passenger/hop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ module Ioki
module Model
module Passenger
class Hop < Base
def self.schema_path
# passenger_api--hop
# passenger_api--hop--drt_hop
# passenger_api--hop--public_transport_hop
# passenger_api--hop--walking_hop

# Only public transport schema includes all attributes:
'passenger_api--hop--public_transport_hop'
end

attribute :type, on: :read, type: :string
attribute :duration, on: :read, type: :integer
attribute :track, on: :read, type: :string
Expand Down
2 changes: 2 additions & 0 deletions lib/ioki/model/passenger/hop_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Ioki
module Model
module Passenger
class HopDetails < Base
unvalidated true

attribute :direction, on: :read, type: :string
attribute :name, on: :read, type: :string
attribute :transport_type, on: :read, type: :string
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/logpay_address_residence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class LogpayAddressResidence < Base
def self.schema_path
'passenger_api--logpay_customer_schema--address_residence'
end

attribute :to1, on: :create, type: :string
attribute :street, on: :create, type: :string
attribute :post_code, on: :create, type: :string
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/logpay_customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class LogpayCustomer < Base
def self.schema_path
'passenger_api--logpay_customer_schema'
end

attribute :payment_method_type, on: :create, type: :string
attribute :email, on: :create, type: :string
attribute :person, on: :create, type: :object, class_name: 'LogpayPerson'
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/logpay_payment_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class LogpayPaymentMethod < Base
def self.schema_path
'passenger_api--logpay_payment_method_schema'
end

attribute :payment_method_type, on: :create, type: :string
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/logpay_person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class LogpayPerson < Base
def self.schema_path
'passenger_api--logpay_customer_schema--person'
end

attribute :gender, on: :create, type: :string
attribute :forename, on: :create, type: :string
attribute :surname, on: :create, type: :string
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/logpay_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class LogpayUrl < Base
def self.schema_path
'passenger_api--logpay_payment_method_setup_url'
end

attribute :url, on: :create, type: :string
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/notification_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class NotificationSetting < Base
def self.schema_path
'passenger_api--notification_setting'
end

attribute :id, on: :read, type: :string
attribute :type, on: :read, type: :string
attribute :name, on: [:read, :update], type: :string
Expand Down
2 changes: 2 additions & 0 deletions lib/ioki/model/passenger/notification_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Ioki
module Model
module Passenger
class NotificationSettings < Base
unvalidated true

base 'Array', item_class_name: 'NotificationSetting'
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/payment_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class PaymentMethod < Base
def self.schema_path
'passenger_api--payment_method_schema'
end

attribute :type, on: :read, type: :string
attribute :id, on: [:read, :create], omit_if_nil_on: :create, type: :string
attribute :created_at, on: :read, type: :date_time
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/payment_method_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class PaymentMethodDetails < Base
def self.schema_path
'passenger_api--payment_method_details_schema'
end

attribute :braintree_nonce, on: :create, type: :string
attribute :paypal_secure_element, on: :create, type: :string
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/service_credit_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class ServiceCreditCreate < Base
def self.schema_path
'passenger_api--service_credit_schema'
end

attribute :cost, type: :integer, on: :create
attribute :value, type: :integer, on: :create
attribute :payment_method, type: :object, on: :create, class_name: 'PaymentMethod'
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/tip_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Passenger
class TipCreate < Base
def self.schema_path
'passenger_api--tip_schema'
end

attribute :amount, on: :create, type: :integer
attribute :payment_method, on: :create, type: :object, class_name: 'PaymentMethod'
end
Expand Down
4 changes: 0 additions & 4 deletions lib/ioki/model/passenger/tipping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ module Ioki
module Model
module Passenger
class Tipping < Base
def self.schema_path
'passenger_api--product--tipping'
end

attribute :maximum, on: :read, type: :object, class_name: 'Money'
attribute :minimum, on: :read, type: :object, class_name: 'Money'
attribute :suggestions, on: :read, type: :array, class_name: 'Money'
Expand Down
3 changes: 0 additions & 3 deletions lib/ioki/model/platform/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module Ioki
module Model
module Platform
class Base < Ioki::Model::Base
def self.specification_scope
'platform_api--v20210101'
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/platform/multilanguage_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Platform
class MultilanguageString < Base
def self.schema_path
'multilanguage_string'
end

attribute :type, on: :read, type: :string
attribute :name, on: :read, type: :string
attribute :translations, on: :read, type: :array, class_name: 'Translation'
Expand Down
4 changes: 4 additions & 0 deletions lib/ioki/model/platform/translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Ioki
module Model
module Platform
class Translation < Base
def self.schema_path
'translation'
end

attribute :type, on: :read, type: :string
attribute :language, on: :read, type: :string
attribute :text, on: :read, type: :string
Expand Down
4 changes: 0 additions & 4 deletions lib/ioki/model/webhooks/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ module Ioki
module Model
module Webhooks
class Base < Ioki::Model::Base
def self.specification_scope
'webhooks--v20201201'
end

def self.valid_definition?(_definition)
true
end
Expand Down
12 changes: 11 additions & 1 deletion lib/ioki/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ def camelize(term)
string
end

def underscore(camel_cased_word)
camel_cased_word
.to_s
.gsub('::', '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
end

# activesupport/lib/active_support/core_ext/object/blank.rb
def blank?(value)
value.respond_to?(:empty?) ? !!value.empty? : !value
end

module_function :camelize, :blank?
module_function :camelize, :underscore, :blank?

module ModuleMixins
# activesupport/lib/active_support/core_ext/module/introspection.rb
Expand Down
Loading
Loading