Skip to content

Commit

Permalink
Merge branch 'main' into MAP-944-daily-ipt
Browse files Browse the repository at this point in the history
  • Loading branch information
danbenton-mojdt authored Apr 22, 2024
2 parents c87b27f + a6162f7 commit 4d75140
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/controllers/sre_swagger_docs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class SreSwaggerDocsController < ApplicationController
def swagger_ui
redirect_to '/api-docs/index.html'
end

def open_api_json
render json: YAML.load_file('swagger/base/swagger.yaml')
end
end
1 change: 1 addition & 0 deletions config/initializers/rswag-ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

c.swagger_endpoint '/api-docs/v2/swagger.yaml', 'PECS4 API V2 Docs'
c.swagger_endpoint '/api-docs/v1/swagger.yaml', 'PECS4 API V1 Docs'
c.swagger_endpoint '/api-docs/base/swagger.yaml', 'PECS4 API Base Docs'
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
if !Rails.env.production? || ENV['SERVE_API_DOCS']
mount Rswag::Ui::Engine => '/api-docs'
mount Rswag::Api::Engine => '/api-docs'
get '/swagger-ui.html', to: 'sre_swagger_docs#swagger_ui'
get '/v3/api-docs', to: 'sre_swagger_docs#open_api_json'
end

get '/health', to: 'status#health', format: :json
Expand Down
100 changes: 100 additions & 0 deletions spec/swagger/swagger_doc_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
:basePath: "/api/base"
:openapi: 3.0.1
:info:
:title: PECS4 Base API Docs
:version: v2
:description: |
Book A Secure Move supplier and frontend API.
:consumes:
- application/vnd.api+json
:produces:
- application/vnd.api+json; version=2
:servers:
- :url: http://localhost:3000/
:description: Local development (localhost)
- :url: https://hmpps-book-secure-move-api-dev.apps.cloud-platform.service.justice.gov.uk/
:description: Dev API
- :url: https://hmpps-book-secure-move-api-staging.apps.cloud-platform.service.justice.gov.uk/
:description: Staging API
- :url: https://hmpps-book-secure-move-api-uat.apps.cloud-platform.service.justice.gov.uk/
:description: UAT API
- :url: https://hmpps-book-secure-move-api-preprod.apps.cloud-platform.service.justice.gov.uk/a
:description: PreProd API
- :url: https://api.bookasecuremove.service.justice.gov.uk/
:description: Production API
:security:
- :oauth2: [ ]
:components:
:securitySchemes:
:oauth2:
:type: :oauth2
:flows:
:clientCredentials:
:authorizationUrl: "/oauth/authorize"
:tokenUrl: "/oauth/token/"
:scopes: { }
:schemas:
:Category:
:$ref: "../v2/category.yaml#/Category"
:paths:
"/subject-access-request":
get:
summary: "Returns all information related to the specified PRN"
tags:
- SubjectAccessRequest
consumes:
- application/vnd.api+json
parameters:
- "$ref": "../v2/accept_type_parameter.yaml#/Accept"
- "$ref": "../v1/content_type_parameter.yaml#/ContentType"
- "$ref": "../v2/accept_encoding.yaml#/AcceptEncoding"
- name: pnr
in: query
description:
Filters results to only include people identified by their police_national_computer.
This is a case insensitive search.
Either filter[police_national_computer], filter[prison_number] or filter[criminal_records_office]
are supported.
schema:
type: string
example: 07/1435713R
format: string
required: false
responses:
"200":
description: success
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/200"
"204":
description: no content
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/204"
"209":
description: unsuppoted parameter
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/209"
"400":
description: bad request
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/400"
"401":
description: unauthorized
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/401"
"403":
description: forbidden
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/403"
2 changes: 2 additions & 0 deletions spec/swagger_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def load_swagger_yaml(*relative_path)

swagger_doc_v1 = YAML.load_file('spec/swagger/swagger_doc_v1.yaml')
swagger_doc_v2 = YAML.load_file('spec/swagger/swagger_doc_v2.yaml')
swagger_doc_base = YAML.load_file('spec/swagger/swagger_doc_base.yaml')

swagger_doc_v2_integration = swagger_doc_v1.deep_dup

Expand All @@ -33,6 +34,7 @@ def load_swagger_yaml(*relative_path)
config.swagger_docs = {
'v1/swagger.yaml' => swagger_doc_v1,
'v2/swagger.yaml' => swagger_doc_v2_integration,
'base/swagger.yaml' => swagger_doc_base,
}

# Specify the format of the output Swagger file when running 'rswag:specs:swaggerize'.
Expand Down
99 changes: 99 additions & 0 deletions swagger/base/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
basePath: "/api/base"
openapi: 3.0.1
info:
title: PECS4 Base API Docs
version: v2
description: 'Book A Secure Move supplier and frontend API.
'
consumes:
- application/vnd.api+json
produces:
- application/vnd.api+json; version=2
servers:
- url: http://localhost:3000/
description: Local development (localhost)
- url: https://hmpps-book-secure-move-api-dev.apps.cloud-platform.service.justice.gov.uk/
description: Dev API
- url: https://hmpps-book-secure-move-api-staging.apps.cloud-platform.service.justice.gov.uk/
description: Staging API
- url: https://hmpps-book-secure-move-api-uat.apps.cloud-platform.service.justice.gov.uk/
description: UAT API
- url: https://hmpps-book-secure-move-api-preprod.apps.cloud-platform.service.justice.gov.uk/a
description: PreProd API
- url: https://api.bookasecuremove.service.justice.gov.uk/
description: Production API
security:
- oauth2: []
components:
securitySchemes:
oauth2:
type: oauth2
flows:
clientCredentials:
authorizationUrl: "/oauth/authorize"
tokenUrl: "/oauth/token/"
scopes: {}
schemas:
Category:
"$ref": "../v2/category.yaml#/Category"
paths:
"/subject-access-request":
get:
summary: Returns all information related to the specified PRN
tags:
- SubjectAccessRequest
consumes:
- application/vnd.api+json
parameters:
- "$ref": "../v2/accept_type_parameter.yaml#/Accept"
- "$ref": "../v1/content_type_parameter.yaml#/ContentType"
- "$ref": "../v2/accept_encoding.yaml#/AcceptEncoding"
- name: pnr
in: query
description: Filters results to only include people identified by their police_national_computer.
This is a case insensitive search. Either filter[police_national_computer],
filter[prison_number] or filter[criminal_records_office] are supported.
schema:
type: string
example: 07/1435713R
format: string
required: false
responses:
'200':
description: success
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/200"
'204':
description: no content
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/204"
'209':
description: unsuppoted parameter
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/209"
'400':
description: bad request
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/400"
'401':
description: unauthorized
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/401"
'403':
description: forbidden
content:
application/vnd.api+json:
schema:
"$ref": "../v2/get_subject_access_request_responses.yaml#/403"
34 changes: 33 additions & 1 deletion swagger/v2/get_subject_access_request_responses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,36 @@
errors:
type: array
items:
$ref: errors.yaml#/BadRequest
$ref: "../v1/errors.yaml#/BadRequest"
'401':
type: object
required:
- errors
properties:
errors:
type: array
items:
type: object
properties:
title:
type: string
example: Not authorized
detail:
type: string
example: Valid authorisation token required
'403':
type: object
required:
- errors
properties:
errors:
type: array
items:
type: object
properties:
title:
type: string
example: Forbidden
detail:
type: string
example: "Missing role: ROLE_SAR_DATA_ACCESS"

0 comments on commit 4d75140

Please sign in to comment.