diff --git a/README.md b/README.md index 3869fe2e..a03dc1f5 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,8 @@ RSpec::OpenAPI.path = -> (example) { end } +RSpec::OpenAPI.title = 'OpenAPI Documentation' + # Disable generating `example` RSpec::OpenAPI.enable_example = false diff --git a/lib/rspec/openapi.rb b/lib/rspec/openapi.rb index c91b054e..309aa021 100644 --- a/lib/rspec/openapi.rb +++ b/lib/rspec/openapi.rb @@ -15,6 +15,7 @@ module RSpec::OpenAPI @path = 'doc/openapi.yaml' + @title = File.basename(Dir.pwd) @comment = nil @enable_example = true @description_builder = ->(example) { example.description } @@ -29,6 +30,7 @@ module RSpec::OpenAPI class << self attr_accessor :path, + :title, :comment, :enable_example, :description_builder, diff --git a/lib/rspec/openapi/result_recorder.rb b/lib/rspec/openapi/result_recorder.rb index 1ff6b560..d1c55c64 100644 --- a/lib/rspec/openapi/result_recorder.rb +++ b/lib/rspec/openapi/result_recorder.rb @@ -7,7 +7,7 @@ def initialize(path_records) end def record_results! - title = File.basename(Dir.pwd) + title = RSpec::OpenAPI.title @path_records.each do |path, records| RSpec::OpenAPI::SchemaFile.new(path).edit do |spec| schema = RSpec::OpenAPI::DefaultSchema.build(title) diff --git a/spec/rails/doc/openapi.json b/spec/rails/doc/openapi.json index 07f98407..2bbfb607 100644 --- a/spec/rails/doc/openapi.json +++ b/spec/rails/doc/openapi.json @@ -1,7 +1,7 @@ { "openapi": "3.0.3", "info": { - "title": "rspec-openapi", + "title": "OpenAPI Documentation", "version": "1.0.0", "description": "My beautiful API", "license": { diff --git a/spec/rails/doc/openapi.yaml b/spec/rails/doc/openapi.yaml index 3ea218c6..0f698646 100644 --- a/spec/rails/doc/openapi.yaml +++ b/spec/rails/doc/openapi.yaml @@ -5,7 +5,7 @@ --- openapi: 3.0.3 info: - title: rspec-openapi + title: OpenAPI Documentation version: 1.0.0 description: My beautiful API license: diff --git a/spec/requests/rails_spec.rb b/spec/requests/rails_spec.rb index c6b61558..cdd96a65 100644 --- a/spec/requests/rails_spec.rb +++ b/spec/requests/rails_spec.rb @@ -7,6 +7,7 @@ require File.expand_path('../rails/config/environment', __dir__) require 'rspec/rails' +RSpec::OpenAPI.title = 'OpenAPI Documentation' RSpec::OpenAPI.request_headers = %w[X-Authorization-Token] RSpec::OpenAPI.response_headers = %w[X-Cursor] RSpec::OpenAPI.path = File.expand_path("../rails/doc/openapi.#{ENV.fetch('OPENAPI_OUTPUT', nil)}", __dir__)