mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:50:00 +08:00
a93ef2926d
Adding in rswag will allow us to write spec files to document and test our api.
44 lines
1.5 KiB
Ruby
44 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
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.swagger_root = Rails.root.join('openapi').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 swagger_root
|
|
# By default, the operations defined in spec files are added to the first
|
|
# document below. You can override this behavior by adding a swagger_doc tag to the
|
|
# the root example_group in your specs, e.g. describe '...', swagger_doc: 'v2/swagger.json'
|
|
config.swagger_docs = {
|
|
'openapi.yaml' => {
|
|
openapi: '3.0.3',
|
|
info: {
|
|
title: 'Discourse API Documentation',
|
|
version: 'latest'
|
|
},
|
|
paths: {},
|
|
servers: [
|
|
{
|
|
url: 'https://{defaultHost}',
|
|
variables: {
|
|
defaultHost: {
|
|
default: 'discourse.example.com'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
# Specify the format of the output Swagger file when running 'rswag:specs:swaggerize'.
|
|
# The swagger_docs 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.swagger_format = :yaml
|
|
end
|