-
Notifications
You must be signed in to change notification settings - Fork 64
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 #171
Comments
How about #162 |
Ah interesting. My usecase is slightly different. I would favour a proc on |
@exoego @alexpapworth, Would it be ideal to assign the title based on the path of the example, or on the file path of the resulting schema? Because if the example is used, I think there could be more titles than schema files, and titles would end up being overwritten if not managed properly. I can provide a solution for both, let me know which would be the preferred configuration: # Option A - Resulting schema file path:
RSpec::OpenAPI.title = -> (path) {
case path
when %r[doc/openapi/v1.yaml] then 'API v1 Documentation'
when %r[doc/openapi/v2.yaml] then 'API v2 Documentation'
else 'OpenAPI Documentation'
end
}
# Option B - Example file path:
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
} |
Ooh interesting. I'm leaning towards Option B, because then the lambda will take the same parameters as |
My use case is generating different openapi files from different RSpec request files. The
RSpec::OpenAPI.path
proc is great to export YAML to different files, but I was surprised to see I couldn't do the same withRSpec::OpenAPI.title
Unfortunately the following snippet generates:
title: !ruby/object:Proc {}
The text was updated successfully, but these errors were encountered: