Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom title #147

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ RSpec::OpenAPI.path = -> (example) {
end
}

RSpec::OpenAPI.title = 'OpenAPI Documentation'

# Disable generating `example`
RSpec::OpenAPI.enable_example = false

Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/openapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -29,6 +30,7 @@ module RSpec::OpenAPI

class << self
attr_accessor :path,
:title,
:comment,
:enable_example,
:description_builder,
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/openapi/result_recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/rails/doc/openapi.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi": "3.0.3",
"info": {
"title": "rspec-openapi",
"title": "OpenAPI Documentation",
"version": "1.0.0",
"description": "My beautiful API",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion spec/rails/doc/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---
openapi: 3.0.3
info:
title: rspec-openapi
title: OpenAPI Documentation
version: 1.0.0
description: My beautiful API
license:
Expand Down
1 change: 1 addition & 0 deletions spec/requests/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
Loading