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

More intelligent schema updates #48

Closed
k0kubun opened this issue Mar 30, 2022 · 0 comments · Fixed by #55
Closed

More intelligent schema updates #48

k0kubun opened this issue Mar 30, 2022 · 0 comments · Fixed by #55

Comments

@k0kubun
Copy link
Collaborator

k0kubun commented Mar 30, 2022

https://github.com/k0kubun/rspec-openapi/blob/v0.4.8/lib/rspec/openapi/schema_merger.rb#L28

Background

Currently, we have two ways to use rspec-openapi:

  1. Delete the OpenAPI schema file and then run rspec-openapi for all tests to build it from scratch.
  2. Just run rspec-openapi and update auto-generated fields while leaving all past changes.

By default, it works in mode 2 because it allows you to incrementally update the schema and also leave manual changes for fields that rspec-openapi cannot automatically generate.

Problem

However, the default behavior, mode 2, sometimes has a problem. As described in #47, when you delete a parameter, even if you remove the parameter and rerun the same spec, it will not delete such obsoleted fields for you.

Proposed Solution

We could possibly build each endpoint from scratch, but leaving keys that rspec-openapi does NOT support. When you run a single spec that requests a route, everything under the path/method should be erased while leaving keys that rspec-openapi cannot update as is, and then changes generated by rspec-openapi should be added to it.

It does mean that you will need to run multiple specs for the same endpoint when some tests are testing only some subset of parameters and you need to run all of them to document everything, but generally, running a single spec file or a describe block should be enough and it's probably not too hard.

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 a pull request may close this issue.

1 participant