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

Evaluate proc for RSpec::OpenAPI.title #240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

josefggx
Copy link

Description:

Solution to #171. With the additional logic you can make the title dynamic using the same approach used with the path, and maintain backward compatibility. This allows the generation of individual schema files, each with its own title.

Example:

It's possible to assign titles in 2 ways:

# Change the default title of the generated schema
RSpec::OpenAPI.title = 'OpenAPI Documentation'

# Or generate individual titles for your partial schema files, given an RSpec example
RSpec::OpenAPI.title = -> (example) {
  case example.file_path
  when %r[spec/requests/api/v1/] then 'API v1 Documentation'
  when %r[spec/requests/api/v2/] then 'API v2 Documentation'
  else 'OpenAPI Documentation'
  end
}

I updated the documentation with this information. I left a comment with an alternative solution in case it's preferred

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant