Skip to content

Commit

Permalink
CASMCMS-8965: Update sessions controller to provide error responses c…
Browse files Browse the repository at this point in the history
…onsistently and correctly
  • Loading branch information
mharding-hpe committed Feb 6, 2025
1 parent 7126194 commit 2c843b9
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 92 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- CASMCMS-9274: Prevent [`SNYK-PYTHON-WERKZEUG-6808933`](https://security.snyk.io/vuln/SNYK-PYTHON-WERKZEUG-6808933) from causing builds to fail.
- CASMCMS-9265: Improve Python type annotations in sessions controller code

### Fixed
- CASMCMS-8965: Update sessions controller to provide error responses consistently and correctly

### Dependencies
- Bumped Python dependency versions.

Expand Down
172 changes: 119 additions & 53 deletions api/openapi.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -263,39 +263,6 @@ components:
example: "Compute"
minLength: 1
maxLength: 127
ProblemDetails:
description: An error response for RFC 7807 problem details.
type: object
properties:
type:
description: |
Relative URI reference to the type of problem which includes human
readable documentation.
type: string
format: uri
default: "about:blank"
title:
description: |
Short, human-readable summary of the problem, should not change by
occurrence.
type: string
status:
description: HTTP status code
type: integer
example: 400
instance:
description: |
A relative URI reference that identifies the specific occurrence of
the problem
format: uri
type: string
detail:
description: |
A human-readable explanation specific to this occurrence of the
problem. Focus on helping correct the problem, rather than giving
debugging information.
type: string
additionalProperties: false
SessionLimit:
type: string
description: |
Expand Down Expand Up @@ -1115,6 +1082,104 @@ components:
minProperties: 1
maxProperties: 1024

# Error response schemas
ProblemDetails:
description: An error response for RFC 7807 problem details.
type: object
properties:
type:
description: |
Relative URI reference to the type of problem which includes human
readable documentation.
type: string
format: uri
default: "about:blank"
title:
description: |
Short, human-readable summary of the problem, should not change by
occurrence.
type: string
status:
description: HTTP status code
type: integer
example: 400
instance:
description: |
A relative URI reference that identifies the specific occurrence of
the problem
format: uri
type: string
detail:
description: |
A human-readable explanation specific to this occurrence of the
problem. Focus on helping correct the problem, rather than giving
debugging information.
type: string
additionalProperties: false
# OAS 3.0 does not support constant values
# The closest we can do is single-value enum + default
ProblemAlreadyExists:
type: object
properties:
title:
type: string
enum: [ "The resource to be created already exists" ]
default: "The resource to be created already exists"
status:
type: integer
enum: [ 409 ]
default: 409
additionalProperties: true
ProblemBadRequest:
type: object
properties:
title:
type: string
enum: [ "Bad Request" ]
default: "Bad Request"
status:
type: integer
enum: [ 400 ]
default: 400
additionalProperties: true
ProblemResourceNotFound:
type: object
properties:
title:
type: string
enum: [ "The resource was not found" ]
default: "The resource was not found"
status:
type: integer
enum: [ 404 ]
default: 404
additionalProperties: true
ProblemUpdateConflict:
type: object
properties:
title:
type: string
enum: [ "The update was not allowed due to a conflict" ]
default: "The update was not allowed due to a conflict"
additionalProperties: true
ProblemServiceUnavailable:
type: object
properties:
title:
type: string
enum: [ "Service Unavailable" ]
default: "Service Unavailable"
additionalProperties: true
ProblemInternalError:
type: object
properties:
title:
type: string
enum: [ "An Internal Server Error occurred handling the request" ]
default: "An Internal Server Error occurred handling the request"
additionalProperties: true


requestBodies:
V2sessionCreateRequest:
description: The information to create a Session
Expand Down Expand Up @@ -1249,57 +1314,56 @@ components:
application/json:
schema:
$ref: '#/components/schemas/V2Options'

# Errors
AlreadyExists:
description: The resource to be created already exists
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
allOf:
- $ref: '#/components/schemas/ProblemDetails'
- $ref: '#/components/schemas/ProblemAlreadyExists'
BadRequest:
description: Bad Request
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
BadRequestOrMultiTenancyNotSupported:
description: |
Multi-tenancy is not supported for this request.
If no tenant was specified, then the request was bad for another reason.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
MultiTenancyNotSupported:
description: Multi-tenancy is not supported for this BOS request.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
allOf:
- $ref: '#/components/schemas/ProblemDetails'
- $ref: '#/components/schemas/ProblemBadRequest'
ResourceNotFound:
description: The resource was not found.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
allOf:
- $ref: '#/components/schemas/ProblemDetails'
- $ref: '#/components/schemas/ProblemResourceNotFound'
UpdateConflict:
description: The update was not allowed due to a conflict.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
allOf:
- $ref: '#/components/schemas/ProblemDetails'
- $ref: '#/components/schemas/ProblemUpdateConflict'
ServiceUnavailable:
description: Service Unavailable
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
allOf:
- $ref: '#/components/schemas/ProblemDetails'
- $ref: '#/components/schemas/ProblemServiceUnavailable'
InternalError:
description: An Internal Server Error occurred handling the request.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
allOf:
- $ref: '#/components/schemas/ProblemDetails'
- $ref: '#/components/schemas/ProblemInternalError'

parameters:
TemplateIdPathParam:
Expand Down Expand Up @@ -1553,6 +1617,8 @@ paths:
$ref: '#/components/responses/V2SessionDetails'
400:
$ref: '#/components/responses/BadRequest'
409:
$ref: '#/components/responses/AlreadyExists'
get:
summary: List Sessions
parameters:
Expand Down
Loading

0 comments on commit 2c843b9

Please sign in to comment.