Skip to content

Commit

Permalink
Fix arrayed uploaded file examples
Browse files Browse the repository at this point in the history
  • Loading branch information
champierre committed Jul 6, 2023
1 parent 0c92c20 commit df08a26
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/rspec/openapi/schema_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
# @return [Hash]
def build(record)
response = {
description: record.description,
description: record.description
}

response_headers = build_response_headers(record)
Expand All @@ -16,8 +16,8 @@ def build(record)
response[:content] = {
normalize_content_type(record.response_content_type) => {
schema: build_property(record.response_body, disposition: disposition),
example: response_example(record, disposition: disposition),
}.compact,
example: response_example(record, disposition: disposition)
}.compact
}
end

Expand All @@ -31,11 +31,11 @@ def build(record)
parameters: build_parameters(record),
requestBody: build_request_body(record),
responses: {
record.status.to_s => response,
},
}.compact,
},
},
record.status.to_s => response
}
}.compact
}
}
}
end

Expand Down Expand Up @@ -65,7 +65,7 @@ def build_parameters(record)
in: 'path',
required: true,
schema: build_property(try_cast(value)),
example: (try_cast(value) if example_enabled?),
example: (try_cast(value) if example_enabled?)
}.compact
end

Expand All @@ -75,7 +75,7 @@ def build_parameters(record)
in: 'query',
required: record.required_request_params.include?(key),
schema: build_property(try_cast(value)),
example: (try_cast(value) if example_enabled?),
example: (try_cast(value) if example_enabled?)
}.compact
end

Expand All @@ -85,7 +85,7 @@ def build_parameters(record)
in: 'header',
required: true,
schema: build_property(try_cast(value)),
example: (try_cast(value) if example_enabled?),
example: (try_cast(value) if example_enabled?)
}.compact
end

Expand All @@ -99,7 +99,7 @@ def build_response_headers(record)

record.response_headers.each do |key, value|
headers[key] = {
schema: build_property(try_cast(value)),
schema: build_property(try_cast(value))
}.compact
end

Expand All @@ -124,9 +124,9 @@ def build_request_body(record)
content: {
normalize_content_type(record.request_content_type) => {
schema: build_property(record.request_params),
example: (build_example(record.request_params) if example_enabled?),
}.compact,
},
example: (build_example(record.request_params) if example_enabled?)
}.compact
}
}
end

Expand Down Expand Up @@ -199,7 +199,7 @@ def adjust_params(value)
adjust_params(v)
when Array
result = v.map do |item|
item.is_a?(ActionDispatch::Http::UploadedFile) ? item.original_filename : item
adjust_params(item)
end
value[key] = result
end
Expand Down

0 comments on commit df08a26

Please sign in to comment.