5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/openapi_ruby/schemas_controller.rb', line 5
def show
schema_name = params[:id]
config = OpenapiRuby.configuration
schema_config = config.schemas[schema_name.to_sym]
return head :not_found unless schema_config
file_path = schema_file_path(schema_name)
return head :not_found unless file_path && File.exist?(file_path)
content = File.read(file_path)
if schema_config[:openapi_filter]
doc = parse_content(file_path, content)
schema_config[:openapi_filter].call(doc, request)
content = serialize_doc(file_path, doc)
end
content_type = file_path.end_with?(".json") ? "application/json" : "application/x-yaml"
render plain: content, content_type: content_type
end
|