From 37b196a2fd02f94f3d88aa03ef40a5324e85988f Mon Sep 17 00:00:00 2001 From: Matt Christianson Date: Fri, 26 Apr 2024 09:32:24 -0400 Subject: [PATCH] Add 404 to rswag, add generated swagger --- .../swagger/claims_api/v2/dev/swagger.json | 75 +++++++++++++++++-- .../veterans/rswag_power_of_attorney_spec.rb | 29 +++++++ 2 files changed, 97 insertions(+), 7 deletions(-) diff --git a/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json b/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json index bc5b78f3b26..0a22c743e2b 100644 --- a/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json +++ b/modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json @@ -6072,7 +6072,7 @@ "application/json": { "example": { "data": { - "id": "6be9b240-267c-4c9c-b8d5-af1cd4068308", + "id": "85570baa-5023-485d-9616-014117c7f9c3", "type": "forms/526", "attributes": { "veteran": { @@ -8156,8 +8156,8 @@ "id": "1", "type": "intent_to_file", "attributes": { - "creationDate": "2024-04-24", - "expirationDate": "2025-04-24", + "creationDate": "2024-04-26", + "expirationDate": "2025-04-26", "type": "compensation", "status": "active" } @@ -8865,6 +8865,67 @@ } } }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "example": { + "errors": [ + { + "title": "Resource not found", + "status": "404", + "detail": "Resource not found", + "source": { + "pointer": "/Users/matthewchristianson/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/rspec-mocks-3.13.0/lib/rspec/mocks/message_expectation.rb:188:in `block in and_raise'" + } + } + ] + }, + "schema": { + "required": [ + "errors" + ], + "properties": { + "errors": { + "type": "array", + "items": { + "additionalProperties": false, + "required": [ + "title", + "detail" + ], + "properties": { + "title": { + "type": "string", + "description": "HTTP error title" + }, + "detail": { + "type": "string", + "description": "HTTP error detail" + }, + "status": { + "type": "string", + "description": "HTTP error status code" + }, + "source": { + "type": "object", + "additionalProperties": false, + "description": "Source of error", + "properties": { + "pointer": { + "type": "string", + "description": "Pointer to source of error" + } + } + } + } + } + } + } + } + } + } + }, "422": { "description": "Unprocessable Entity", "content": { @@ -8975,7 +9036,7 @@ "application/json": { "example": { "data": { - "id": "867b7baa-8dbe-4053-823f-788218fa6984", + "id": "7d13ac13-edf3-45e9-b5d4-5efece079c5b", "type": "individual", "attributes": { "code": "083", @@ -9671,7 +9732,7 @@ "application/json": { "example": { "data": { - "id": "c54cfb3e-8ec8-48ce-bb19-52847bdd9bde", + "id": "4fa4f1ba-56e1-42da-990d-33b05503a01d", "type": "organization", "attributes": { "code": "083", @@ -11631,11 +11692,11 @@ "application/json": { "example": { "data": { - "id": "af367b07-5484-4eb7-8a2b-3d4bf1ba447c", + "id": "d8d4b85e-53d1-490e-baee-22903dcf3661", "type": "claimsApiPowerOfAttorneys", "attributes": { "status": "submitted", - "dateRequestAccepted": "2024-04-24", + "dateRequestAccepted": "2024-04-26", "representative": { "serviceOrganization": { "poaCode": "074" diff --git a/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb b/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb index 7158c3a3e56..bba80f260d6 100644 --- a/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb +++ b/modules/claims_api/spec/requests/v2/veterans/rswag_power_of_attorney_spec.rb @@ -101,6 +101,35 @@ end end + describe 'Getting a 404 response' do + response '404', 'Resource not found' do + schema JSON.parse(Rails.root.join('spec', 'support', 'schemas', 'claims_api', 'v2', 'errors', + 'power_of_attorney', 'default.json').read) + + let(:veteranId) { 'xxx' } # rubocop:disable RSpec/VariableName + + before do |example| + allow_any_instance_of(ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController).to receive(:show) + .and_raise(Common::Exceptions::ResourceNotFound) + mock_ccg(scopes) do + submit_request(example.metadata) + end + end + + after do |example| + example.metadata[:response][:content] = { + 'application/json' => { + example: JSON.parse(response.body, symbolize_names: true) + } + } + end + + it 'returns a 404 response' do |example| + assert_response_matches_metadata(example.metadata) + end + end + end + describe 'Getting a 422 response' do response '422', 'Unprocessable Entity' do schema JSON.parse(File.read(Rails.root.join('spec', 'support', 'schemas', 'claims_api', 'v2', 'errors',