Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions __tests__/httpServer/apiV1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ describe('HTTP Server API V1', () => {
test.todo('should return 500 for internal server error')
})

describe('GET /api/v1/check', () => {
describe('GET /api/v1/compliance-check', () => {
test('should return 200 and a list of checks', async () => {
const response = await app.get('/api/v1/check')
const response = await app.get('/api/v1/compliance-check')
const storedChecks = await getAllChecks()

expect(response.status).toBe(200)
Expand All @@ -405,9 +405,9 @@ describe('HTTP Server API V1', () => {
test.todo('should return 500 for internal server error')
})

describe('GET /api/v1/check/:checkId', () => {
describe('GET /api/v1/compliance-check/:checkId', () => {
test('should return 200 and a check by ID', async () => {
const response = await app.get('/api/v1/check/1')
const response = await app.get('/api/v1/compliance-check/1')
const storedCheck = await getCheckById(1)

expect(response.status).toBe(200)
Expand All @@ -416,15 +416,15 @@ describe('HTTP Server API V1', () => {
})

test('should return 400 for invalid check ID', async () => {
const response = await app.get('/api/v1/check/invalid')
const response = await app.get('/api/v1/compliance-check/invalid')

expect(response.status).toBe(400)
expect(response.body).toHaveProperty('errors')
expect(response.body.errors[0]).toHaveProperty('message', 'must be integer')
})

test('should return 404 for check not found', async () => {
const response = await app.get('/api/v1/check/9999999')
const response = await app.get('/api/v1/compliance-check/9999999')

expect(response.status).toBe(404)
expect(response.body).toHaveProperty('errors')
Expand Down
4 changes: 2 additions & 2 deletions src/httpServer/routers/apiV1.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function createApiRouter (knex, express) {
}
})

router.get('/check/:checkId', async (req, res) => {
router.get('/compliance-check/:checkId', async (req, res) => {
try {
// Params validation done in swagger
const checkId = parseInt(req.params.checkId, 10)
Expand All @@ -136,7 +136,7 @@ function createApiRouter (knex, express) {
}
})

router.get('/check', async (req, res) => {
router.get('/compliance-check', async (req, res) => {
try {
const checks = await getAllChecks()
res.json(checks)
Expand Down
32 changes: 16 additions & 16 deletions src/httpServer/swagger/api-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/v1/check/{checkId}:
/api/v1/compliance-check/{checkId}:
get:
summary: Get a check by ID
description: Returns a check by ID
operationId: getCheckById
summary: Get a compliance check by ID
description: Returns a compliance check by ID
operationId: getComplianceCheckById
tags:
- Checks
- Compliance Checks
parameters:
- name: checkId
in: path
Expand All @@ -229,19 +229,19 @@ paths:
example: 53
responses:
'200':
description: A check
description: A compliance check
content:
application/json:
schema:
$ref: '#/components/schemas/Check'
$ref: '#/components/schemas/ComplianceCheck'
'400':
description: Bad request, invalid input data
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Check not found
description: Compliance check not found
content:
application/json:
schema:
Expand All @@ -252,22 +252,22 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/v1/check:
/api/v1/compliance-check:
get:
summary: List all checks
description: Returns a list of all checks
operationId: listChecks
summary: List all compliance checks
description: Returns a list of all compliance checks
operationId: listComplianceChecks
tags:
- Checks
- Compliance Checks
responses:
'200':
description: A list of checks
description: A list of compliance checks
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Check'
$ref: '#/components/schemas/ComplianceCheck'
'500':
description: Internal server error
content:
Expand Down Expand Up @@ -328,7 +328,7 @@ paths:

components:
schemas:
Check:
ComplianceCheck:
type: object
additionalProperties: false
properties:
Expand Down
Loading