diff --git a/docs/openapi/openapi.yaml b/docs/openapi/openapi.yaml index a76e8245..2300124e 100644 --- a/docs/openapi/openapi.yaml +++ b/docs/openapi/openapi.yaml @@ -68,6 +68,12 @@ paths: application/json: schema: $ref: "#/components/schemas/BadRequestError" + "404": + description: Case not found. + content: + application/json: + schema: + $ref: "#/components/schemas/NotFoundError" x-amazon-apigateway-auth: type: "AWS_IAM" x-amazon-apigateway-integration: @@ -189,6 +195,29 @@ components: example: - source: "/uid" detail: "invalid uid format" + NotFoundError: + allOf: + - $ref: "#/components/schemas/AbstractError" + - type: object + properties: + code: + enum: ["NOT_FOUND"] + errors: + type: array + items: + type: object + required: + - source + - detail + properties: + source: + type: string + format: jsonpointer + detail: + type: string + example: + - source: "/uid" + detail: "uid not found" Lpa: allOf: - $ref: "#/components/schemas/InitialLpa" diff --git a/internal/shared/problem.go b/internal/shared/problem.go index 57fac580..890a1883 100644 --- a/internal/shared/problem.go +++ b/internal/shared/problem.go @@ -48,6 +48,12 @@ var ProblemUnauthorisedRequest Problem = Problem{ Detail: "Invalid JWT", } +var ProblemNotFoundRequest Problem = Problem{ + StatusCode: 404, + Code: "NOT_FOUND", + Detail: "Record not found", +} + func (problem Problem) Respond() (events.APIGatewayProxyResponse, error) { var errorString = "" for _, ve := range problem.Errors { diff --git a/lambda/get/main.go b/lambda/get/main.go index c9cc7e47..710bf36b 100644 --- a/lambda/get/main.go +++ b/lambda/get/main.go @@ -38,7 +38,7 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe if err != nil { l.logger.Print(err) - return shared.ProblemInternalServerError.Respond() + return shared.ProblemNotFoundRequest.Respond() } body, err := json.Marshal(lpa)