Class: PUNK::GenerateSwaggerService
Instance Attribute Summary
Attributes included from Validatable
Instance Method Summary collapse
Methods inherited from Service
Methods included from Loggable
#exception, #logger, #profile_debug, #profile_info, #profile_trace
Methods inherited from Runnable
args, #method_missing, #respond_to_missing?
Methods included from Validatable
#default_validation_helpers_options, #get_column_value, #valid?, #validate, #validates_not_empty
Methods included from Plugins::Validation::InstanceMethods
#validates_email, #validates_event, #validates_phone, #validates_state, #validates_url
Methods inherited from Settings
#method_missing, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PUNK::Runnable
Instance Method Details
#process ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/punk/services/generate_swagger.rb', line 5 def process path = File.join(PUNK.get.app.path, "..", "www", "swagger.json") raise InternalServerError, "swagger.json already exists" if File.exist?(path) && !PUNK.env.test? require "swagger_yard" require_relative "../helpers/swagger" SwaggerYard. SwaggerYard.configure do |config| config.api_version = PUNK.version config.title = PUNK.get.app.name config.description = PUNK.get.app.description config.api_base_path = PUNK.get.app.url config.controller_path = [File.join(PUNK.get.app.path, "routes", "**", "*"), File.join(__dir__, "..", "routes", "**", "*")] config.model_path = [File.join(__dir__, "..", "models", "**", "*"), File.join(__dir__, "..", "views", "**", "*"), File.join(PUNK.get.app.path, "models", "**", "*")] end spec = SwaggerYard::OpenAPI.new blob = JSON.pretty_generate(spec.to_h) File.open(path, "w") { |f| f << blob } unless PUNK.env.test? blob end |