mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-22 22:06:43 +00:00
remove commented code.
This commit is contained in:
parent
2af7c13e59
commit
e53f2ca257
@ -37,96 +37,6 @@ module Rswag
|
||||
end
|
||||
end
|
||||
|
||||
## OA3
|
||||
# # MUST HAVES
|
||||
# # need to run ```npm install``` in rswag-ui dir to get assets to load
|
||||
# # not sure if its an asset issue or what but this should load => http://localhost:3000/api-docs/index.html
|
||||
# # TODO: fix examples in the main README
|
||||
|
||||
# def request_body(attributes)
|
||||
# # can make this generic, and accept any incoming hash (like parameter method)
|
||||
# attributes.compact!
|
||||
|
||||
# if metadata[:operation][:requestBody].blank?
|
||||
# metadata[:operation][:requestBody] = attributes
|
||||
# elsif metadata[:operation][:requestBody] && metadata[:operation][:requestBody][:content]
|
||||
# # merge in
|
||||
# content_hash = metadata[:operation][:requestBody][:content]
|
||||
# incoming_content_hash = attributes[:content]
|
||||
# content_hash.merge!(incoming_content_hash) if incoming_content_hash
|
||||
# end
|
||||
# end
|
||||
|
||||
# def request_body_json(schema:, required: true, description: nil, examples: nil)
|
||||
# passed_examples = Array(examples)
|
||||
# content_hash = { 'application/json' => { schema: schema, examples: examples }.compact! || {} }
|
||||
# request_body(description: description, required: required, content: content_hash)
|
||||
# if passed_examples.any?
|
||||
# # the request_factory is going to have to resolve the different ways that the example can be given
|
||||
# # it can contain a 'value' key which is a direct hash (easiest)
|
||||
# # it can contain a 'external_value' key which makes an external call to load the json
|
||||
# # it can contain a '$ref' key. Which points to #/components/examples/blog
|
||||
# passed_examples.each do |passed_example|
|
||||
# if passed_example.is_a?(Symbol)
|
||||
# example_key_name = passed_example
|
||||
# # TODO: write more tests around this adding to the parameter
|
||||
# # if symbol try and use save_request_example
|
||||
# param_attributes = { name: example_key_name, in: :body, required: required, param_value: example_key_name, schema: schema }
|
||||
# parameter(param_attributes)
|
||||
# elsif passed_example.is_a?(Hash) && passed_example[:externalValue]
|
||||
# param_attributes = { name: passed_example, in: :body, required: required, param_value: passed_example[:externalValue], schema: schema }
|
||||
# parameter(param_attributes)
|
||||
# elsif passed_example.is_a?(Hash) && passed_example['$ref']
|
||||
# param_attributes = { name: passed_example, in: :body, required: required, param_value: passed_example['$ref'], schema: schema }
|
||||
# parameter(param_attributes)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# def request_body_text_plain(required: false, description: nil, examples: nil)
|
||||
# content_hash = { 'test/plain' => { schema: {type: :string}, examples: examples }.compact! || {} }
|
||||
# request_body(description: description, required: required, content: content_hash)
|
||||
# end
|
||||
|
||||
# # TODO: add examples to this like we can for json, might be large lift as many assumptions are made on content-type
|
||||
# def request_body_xml(schema:,required: false, description: nil, examples: nil)
|
||||
# passed_examples = Array(examples)
|
||||
# content_hash = { 'application/xml' => { schema: schema, examples: examples }.compact! || {} }
|
||||
# request_body(description: description, required: required, content: content_hash)
|
||||
# end
|
||||
|
||||
# def request_body_multipart(schema:, description: nil)
|
||||
# content_hash = { 'multipart/form-data' => { schema: schema }}
|
||||
# request_body(description: description, content: content_hash)
|
||||
|
||||
# schema.extend(Hashie::Extensions::DeepLocate)
|
||||
# file_properties = schema.deep_locate ->(_k, v, _obj) { v == :binary }
|
||||
# hash_locator = []
|
||||
|
||||
# file_properties.each do |match|
|
||||
# hash_match = schema.deep_locate ->(_k, v, _obj) { v == match }
|
||||
# hash_locator.concat(hash_match) unless hash_match.empty?
|
||||
# end
|
||||
|
||||
# property_hashes = hash_locator.flat_map do |locator|
|
||||
# locator.select { |_k,v| file_properties.include?(v) }
|
||||
# end
|
||||
|
||||
# existing_keys = []
|
||||
# property_hashes.each do |property_hash|
|
||||
# property_hash.keys.each do |k|
|
||||
# if existing_keys.include?(k)
|
||||
# next
|
||||
# else
|
||||
# file_name = k
|
||||
# existing_keys << k
|
||||
# parameter name: file_name, in: :formData, type: :file, required: true
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
def parameter(attributes)
|
||||
if attributes[:in] && attributes[:in].to_sym == :path
|
||||
attributes[:required] = true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user