rspec-openapi
rspec-openapi copied to clipboard
Generate multiple examples
I tried to do the generation of a few examples as described here. I would like to get a review of my approach before I continue working on this feature.
The very design of this feature is also questionable, perhaps it makes sense to use the feature in roughly this way for simpler cases:
describe '#index', openapi: { enable_examples: true } do
context 'when foo', openapi: { example_name: :foo }
context 'when bar', openapi: { example_name: :bar }
end
In other cases I am concerned about the definition of unique examples, do I need to remove non-unique examples, or should I keep all examples? Maybe both options are needed for flexibility 🤔
@exoego take a look, please
I am fine with the example_name approach.
How does this handle when some test cases have example_name but other cases don't for an endpoint?
In other cases I am concerned about the definition of unique examples, do I need to remove non-unique examples, or should I keep all examples? Maybe both options are needed for flexibility 🤔
I don't get the concern.
When do users specify same example_name to multiple test cases?
@AlexeyMatskevich Hello, I am hoping this PR will resolve the related issue. Do you plan to continue working on it?
@rhiroe Hi, this is a conceptual question for me so far. We realize what we want to solve is to provide some sample examples so that the reader of the documentation can see some cases, which is some hack of OpenAPI limitations. However, how to achieve this is a complex issue where we need to think about design. Then it's a flexibility issue where we want to throw all sample responses into examles or just certain ones, and we usually use factory_bot and from run to run the data is different and that's a problem.
Maybe the author (@exoego ) will have an opinion (sorry I ignored your question before)
p.s. I may have already forgotten my context on this issue.
@AlexeyMatskevich In my personal opinion,
Then it's a flexibility issue where we want to throw all sample responses into examles or just certain ones
For the ones we don't want to include, I think adding openapi: false metadata would be a good approach.
and we usually use factory_bot and from run to run the data is different and that's a problem.
Our team solves this by setting a fixed seed value when the OPENAPI environment variable is present.
RSpec.configure do |config|
config.seed = 1 if ENV['OPENAPI']
@AlexeyMatskevich any more thoughts on progressing with this?