Class: OasContrib::Resolver::Preview
- Defined in:
- lib/oas_contrib/resolver/preview.rb
Overview
Preview command resolver class
Constant Summary
Constants inherited from Base
Base::DEFINED_FILE_EXT, Base::DIR_NAME_META, Base::DIR_NAME_MODEL, Base::DIR_NAME_PATH
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#distribute ⇒ Boolean
Distribute the command artifacts.
-
#initialize(infile, options) ⇒ Preview
constructor
Initialize.
-
#setup ⇒ Boolean
Setup the resolver object.
Methods inherited from Base
#file_ext_check, #input, #input_dir, #input_lambda, #output, #resolve, #v2?, #v3?
Methods included from Interface::Resolver
Constructor Details
#initialize(infile, options) ⇒ Preview
Initialize
10 11 12 13 |
# File 'lib/oas_contrib/resolver/preview.rb', line 10 def initialize(infile, ) @infile = infile @port = ['port'] end |
Instance Method Details
#distribute ⇒ Boolean
Distribute the command artifacts.
27 28 29 30 31 32 33 34 |
# File 'lib/oas_contrib/resolver/preview.rb', line 27 def distribute puts "SwaggerUI listen: http://localhost:#{@port} with: #{@expand_path}" `docker run --rm --name oas_contrib_preview_swagger_ui \ -p #{@port}:8080 -e API_URL=#{@basename} \ -v #{@expand_path}:/usr/share/nginx/html/#{@basename} swaggerapi/swagger-ui` raise 'Preview command needs docker.' unless $?.exitstatus.zero? true end |
#setup ⇒ Boolean
Setup the resolver object.
17 18 19 20 21 22 23 |
# File 'lib/oas_contrib/resolver/preview.rb', line 17 def setup @expand_path = File.(@infile) @basename = File.basename(@expand_path) @infile_ext = File.extname(@infile) file_ext_check true end |