From 627e689757abc7399b96d50b2ef794973503cd76 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 26 Jul 2023 15:52:48 +1000 Subject: [PATCH] Fix swagger-api integration after last update See also: * https://github.com/rswag/rswag/pull/668 --- config/initializers/rswag_api.rb | 2 +- spec/requests/api_docs_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 spec/requests/api_docs_spec.rb diff --git a/config/initializers/rswag_api.rb b/config/initializers/rswag_api.rb index 58c23bf233..15e2107512 100644 --- a/config/initializers/rswag_api.rb +++ b/config/initializers/rswag_api.rb @@ -5,7 +5,7 @@ Rswag::Api.configure do |config| # This is used by the Swagger middleware to serve requests for API descriptions # NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure # that it's configured to generate files in the same folder - config.swagger_root = Rails.root.join("swagger") + config.swagger_root = Rails.root.join("swagger").to_s # Inject a lamda function to alter the returned Swagger prior to serialization # The function will have access to the rack env for the current request diff --git a/spec/requests/api_docs_spec.rb b/spec/requests/api_docs_spec.rb new file mode 100644 index 0000000000..3792522f2d --- /dev/null +++ b/spec/requests/api_docs_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe "API documentation", type: :request do + it "shows the OFN API v1" do + get rswag_ui_path + expect(response).to redirect_to "/api-docs/index.html" + + get "/api-docs/index.html" + expect(response).to have_http_status :success + + expect(response.body).to match "API V1" + end + + it "can load the Swagger config" do + get "/api-docs/v1/swagger.yaml" + expect(response).to have_http_status :success + end +end