Class: RswagSchemaExport::Export
- Inherits:
-
Object
- Object
- RswagSchemaExport::Export
- Defined in:
- lib/rswag_schema_export/schema_export.rb
Instance Method Summary collapse
-
#run ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Details
#run ⇒ Object
rubocop:disable Metrics/AbcSize
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rswag_schema_export/schema_export.rb', line 3 def run # rubocop:disable Metrics/AbcSize abort("Set up RswagSchemaExport.config.schemas") unless RswagSchemaExport.config.schemas RswagSchemaExport.config.schemas.map do |schema| next if File.file?(schema) = "Not found schema at #{schema}. For generate schema run: RAILS_ENV=test rake rswag:specs:swaggerize" abort() end begin client = ::RswagSchemaExport::Client.new(ENV["STAGE"]) RswagSchemaExport.config.schemas.map do |schema| schema_id = schema.gsub(/[^a-zA-Z0-9\-]/, "_") key = "schemas/#{client.app_name}/#{client.stage}_#{schema_id}/versions/#{Time.now.getutc.iso8601}.json" # Upload latest version to the cloud client.upload_file(key, schema) puts("Schema has been successfully exported. Stage: #{client.stage} | Key: #{key}") end puts("Export finished") rescue StandardError => e abort(e.) end end |