-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger_helper.rb
55 lines (50 loc) · 1.86 KB
/
swagger_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true
require 'rails_helper'
Rails.root.glob('spec/requests/support/**/*.rb').sort_by(&:to_s).each { |f| require f }
RSpec.configure do |config|
# Specify a root folder where Swagger JSON files are generated
# NOTE: If you're using the rswag-api to serve API descriptions, you'll need
# to ensure that it's configured to serve Swagger from the same folder
config.openapi_root = Rails.root.join('swagger').to_s
# Define one or more Swagger documents and provide global metadata for each one
# When you run the 'rswag:specs:swaggerize' rake task, the complete Swagger will
# be generated at the provided relative path under openapi_root
# By default, the operations defined in spec files are added to the first
# document below. You can override this behavior by adding a openapi_spec tag to the
# the root example_group in your specs, e.g. describe '...', openapi_spec: 'v2/swagger.json'
config.openapi_specs = {
'swagger.yaml' => {
openapi: '3.0.1',
info: {
title: 'API V1',
version: 'v1'
},
consumes: [ 'application/json' ],
produces: [ 'application/json' ],
paths: {},
components: {
schemas: {
attribute_error: {
type: 'array',
items: { type: 'string' }
}
}
}
# servers: [
# {
# url: 'https://{defaultHost}',
# variables: {
# defaultHost: {
# default: 'www.example.com'
# }
# }
# }
# ]
}
}
# Specify the format of the output Swagger file when running 'rswag:specs:swaggerize'.
# The openapi_specs configuration option has the filename including format in
# the key, this may want to be changed to avoid putting yaml in json files.
# Defaults to json. Accepts ':json' and ':yaml'.
config.openapi_format = :yaml
end