Sha256: 6aa933aa6293bb25dcce441668fc94c7d15cdf49862b4decbbd935e347e5ebed
Contents?: true
Size: 935 Bytes
Versions: 1
Compression:
Stored size: 935 Bytes
Contents
# frozen_string_literal: true module SwaggerDocsGenerator # # Parse Controller classes # # Parse controller classes in Rails application. It's create temporary file # and adding automaticaly tags element. class ParserDefinition < Parser def initialize(controller, name, parameters) super(controller) @name = name @parameters = parameters end def adding_defintion json = JSON.parse(File.read(controller_file)) File.open(controller_file, 'w') do |file| if json.key?('definitions') json['definitions'].merge!(construct_definition) else json['definitions'] = construct_definition end file.puts(JSON.pretty_generate(json)) end end private def construct_definition { format_name => { type: 'object', properties: @parameters } } end def format_name @name.tr(' ', '_').camelize end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
swagger_docs_generator-0.2.0.pre.12 | lib/swagger_docs_generator/parser/definition.rb |