Use rswag to update openapi spec#2085
Merged
Merged
Conversation
sanason
commented
Jun 26, 2026
| @@ -1,19 +0,0 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
Member
Author
There was a problem hiding this comment.
Safe to delete - no routes are mapped to this controller.
sanason
commented
Jun 26, 2026
| @@ -27,6 +27,7 @@ def index | |||
| meta: { | |||
| current_page: cx_responses.current_page, | |||
| size: cx_responses.size, | |||
Member
Author
There was a problem hiding this comment.
Adding this here so it matches the meta block in /forms/{id}/responses.
sanason
commented
Jun 26, 2026
| if current_user.organizational_admin? | ||
| render json: current_user.organization.forms | ||
| .order(:id) | ||
| .limit(100), each_serializer: FormSerializer |
Member
Author
There was a problem hiding this comment.
I don't like this undocumented and arbitrary limit. A safer solution would be to add pagination but the API already has a bunch of unlimited endpoints and I don't think this one is more of a risk than any of them.
sanason
commented
Jun 26, 2026
| end | ||
| namespace :v1 do | ||
| resources :organizations, only: [:index] | ||
| resources :collections, only: [:index] |
Member
Author
There was a problem hiding this comment.
Deleting because this route has no corresponding controller.
sanason
commented
Jun 26, 2026
| it 'expects volume to be 1,000 each (and not the sum of all responses: regression)' do | ||
| expect(csv.class).to eq(CSV::Table) | ||
| expect(csv.size).to eq(2) | ||
|
|
Member
Author
There was a problem hiding this comment.
Changed because the factory changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The purpose of this PR is to update the OpenAPI spec for the V1 Touchpoints API. The updated spec adds documentation for the following endpoints:
It removes documentation for two digital registry endpoints:
Those endpoints still exist but, since the public-facing digital registry was shuttered in 2024, I'm not willing to maintain the documentation for the corresponding API endpoints. /websites is still documented because I know that GSA is still using the website registry as its internal inventory tool.
Adding a tool to automate generation of API documentation
I'm not sure how the OpenAPI spec was maintained previously but there weren't any spec automation libraries listed in the Gemfile. I adopted the Rswag tool to help with automation. Setting up Rswag is how this PR got so big.
With the addition of Rswag, the V1 spec file (public/api/v1/openapi.yml) becomes a generated file. It is generated by the command:
It's still a version controlled file because changes to it should be reviewed since it is human-facing documentation.
Since it is a generated, version-controlled file, I added a CI step to check that developers are re-running the generation script before commits so the spec does not drift from the actual API.Rswag doesn't really reduce the manual effort required to create the OpenAPI spec. But it helps the developer to write accurate documentation because it runs tests that actually call the API and validate the request/response against what the documentation says.
Other miscellaneous changes
jsonby default. It's no longer required to add.jsonto the end of the URL in your API calls (though it still works if you do).AI-assisted: authored with an AI coding agent under human review.